@Test public void testGetQueryParameterValue() { String queryParameterId1 = "qp/variable1"; String queryParameterValue1 = "value1"; String queryParameterId2 = "qp/variable2"; String queryParameterValue2 = "value2"; Predicate predicate = new PredicateBuilder().property(queryParameterId1).equals(queryParameterValue1). and().property(queryParameterId2).equals(queryParameterValue2).toPredicate(); Assert.assertEquals(queryParameterValue1, AbstractResourceProvider.getQueryParameterValue(queryParameterId1, predicate)); Assert.assertFalse(queryParameterValue2.equals(AbstractResourceProvider.getQueryParameterValue(queryParameterId1, predicate))); Assert.assertNull(AbstractResourceProvider.getQueryParameterValue("queryParameterIdNotFound", predicate)); String queryParameterId3 = "qp/variable3"; String queryParameterValue3 = "value3"; predicate = new PredicateBuilder().property(queryParameterId3).equals(queryParameterValue3). and().begin().property(queryParameterId1).equals(queryParameterValue1). and().property(queryParameterId2).equals(queryParameterValue2).end().toPredicate(); Assert.assertEquals(queryParameterValue1, AbstractResourceProvider. getQueryParameterValue(queryParameterId1, predicate)); Assert.assertFalse(queryParameterValue2.equals(AbstractResourceProvider. getQueryParameterValue(queryParameterId1, predicate))); Assert.assertNull(AbstractResourceProvider. getQueryParameterValue("queryParameterIdNotFound", predicate)); Assert.assertEquals(queryParameterValue3, AbstractResourceProvider. getQueryParameterValue(queryParameterId3, predicate)); }
protected static Object getQueryParameterValue(String queryParameterId, Predicate predicate) { Object result = null; if (predicate instanceof EqualsPredicate) { EqualsPredicate equalsPredicate = (EqualsPredicate) predicate; if (queryParameterId.equals(equalsPredicate.getPropertyId())) { return equalsPredicate.getValue(); } } else if (predicate instanceof ArrayPredicate) { ArrayPredicate arrayPredicate = (ArrayPredicate) predicate; for (Predicate predicateItem : arrayPredicate.getPredicates()) { result = getQueryParameterValue(queryParameterId, predicateItem); if (result != null) { return result; } } } return result; }
AbstractResourceProvider extends BaseProvider implements ResourceProvider, ObservableResourceProvider { protected static Object getQueryParameterValue(String queryParameterId, Predicate predicate) { Object result = null; if (predicate instanceof EqualsPredicate) { EqualsPredicate equalsPredicate = (EqualsPredicate) predicate; if (queryParameterId.equals(equalsPredicate.getPropertyId())) { return equalsPredicate.getValue(); } } else if (predicate instanceof ArrayPredicate) { ArrayPredicate arrayPredicate = (ArrayPredicate) predicate; for (Predicate predicateItem : arrayPredicate.getPredicates()) { result = getQueryParameterValue(queryParameterId, predicateItem); if (result != null) { return result; } } } return result; } }
AbstractResourceProvider extends BaseProvider implements ResourceProvider, ObservableResourceProvider { protected static Object getQueryParameterValue(String queryParameterId, Predicate predicate) { Object result = null; if (predicate instanceof EqualsPredicate) { EqualsPredicate equalsPredicate = (EqualsPredicate) predicate; if (queryParameterId.equals(equalsPredicate.getPropertyId())) { return equalsPredicate.getValue(); } } else if (predicate instanceof ArrayPredicate) { ArrayPredicate arrayPredicate = (ArrayPredicate) predicate; for (Predicate predicateItem : arrayPredicate.getPredicates()) { result = getQueryParameterValue(queryParameterId, predicateItem); if (result != null) { return result; } } } return result; } protected  AbstractResourceProvider(Set<String> propertyIds,
                                     Map<Resource.Type, String> keyPropertyIds); }
AbstractResourceProvider extends BaseProvider implements ResourceProvider, ObservableResourceProvider { protected static Object getQueryParameterValue(String queryParameterId, Predicate predicate) { Object result = null; if (predicate instanceof EqualsPredicate) { EqualsPredicate equalsPredicate = (EqualsPredicate) predicate; if (queryParameterId.equals(equalsPredicate.getPropertyId())) { return equalsPredicate.getValue(); } } else if (predicate instanceof ArrayPredicate) { ArrayPredicate arrayPredicate = (ArrayPredicate) predicate; for (Predicate predicateItem : arrayPredicate.getPredicates()) { result = getQueryParameterValue(queryParameterId, predicateItem); if (result != null) { return result; } } } return result; } protected  AbstractResourceProvider(Set<String> propertyIds,
                                     Map<Resource.Type, String> keyPropertyIds); @Override Map<Resource.Type, String> getKeyPropertyIds(); @Override void updateObservers(ResourceProviderEvent event); @Override void addObserver(ResourceProviderObserver observer); static List<ConfigurationRequest> getConfigurationRequests(String parentCategory, Map<String, Object> properties); static void parseProperties(ConfigurationRequest config, String absCategory, String propName, String propValue); }
AbstractResourceProvider extends BaseProvider implements ResourceProvider, ObservableResourceProvider { protected static Object getQueryParameterValue(String queryParameterId, Predicate predicate) { Object result = null; if (predicate instanceof EqualsPredicate) { EqualsPredicate equalsPredicate = (EqualsPredicate) predicate; if (queryParameterId.equals(equalsPredicate.getPropertyId())) { return equalsPredicate.getValue(); } } else if (predicate instanceof ArrayPredicate) { ArrayPredicate arrayPredicate = (ArrayPredicate) predicate; for (Predicate predicateItem : arrayPredicate.getPredicates()) { result = getQueryParameterValue(queryParameterId, predicateItem); if (result != null) { return result; } } } return result; } protected  AbstractResourceProvider(Set<String> propertyIds,
                                     Map<Resource.Type, String> keyPropertyIds); @Override Map<Resource.Type, String> getKeyPropertyIds(); @Override void updateObservers(ResourceProviderEvent event); @Override void addObserver(ResourceProviderObserver observer); static List<ConfigurationRequest> getConfigurationRequests(String parentCategory, Map<String, Object> properties); static void parseProperties(ConfigurationRequest config, String absCategory, String propName, String propValue); static Pattern propertiesAttributesPattern; }