Skip to content

Commit

Permalink
rename GetMetadataWildcardResolver to MetadataFieldsWildcardResolver;
Browse files Browse the repository at this point in the history
add javadoc to MetadataWildcardValidator;

Signed-off-by: Stefan Maute <stefan.maute@bosch.io>
  • Loading branch information
Stefan Maute committed Jun 1, 2022
1 parent 222c8c1 commit c4b24ea
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ private Set<JsonPointer> expandWildcardsInMetadataExpression(final Set<JsonPoint

metadataPointerWithWildcard.stream()
.filter(this::checkIfContainsWildcard)
.map(jsonPointer -> GetMetadataWildcardResolver.resolve(command, entity, jsonPointer))
.map(jsonPointer -> MetadataFieldsWildcardResolver.resolve(command, entity, jsonPointer))
.forEach(resolvedGetMetadataPointers::addAll);

return resolvedGetMetadataPointers;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@
import org.eclipse.ditto.things.model.signals.commands.query.RetrieveThing;

@Immutable
final class GetMetadataWildcardResolver {
final class MetadataFieldsWildcardResolver {

private static final JsonPointer FEATURES_POINTER = JsonPointer.of("features");
private static final JsonPointer PROPERTIES_POINTER = JsonPointer.of("properties");

private GetMetadataWildcardResolver() {
private MetadataFieldsWildcardResolver() {
throw new AssertionError();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,38 +94,101 @@ public static void validateMetadataWildcard(final String commandType, final Stri
}
}

/**
* Matches the passed {@code wildcardExpression} against wildcard regex
* {@code THING_FEATURES_AND_PROPERTIES_WILDCARD_REGEX} and returns {@code true} if they match.
*
* @param wildcardExpression the wildcard expression that should be checked.
* @return {@code true} if the wildcardExpression matches the regex and false if not.
*/
public static boolean matchesThingFeaturesAndPropertiesWildcard(final String wildcardExpression) {
return Pattern.matches(THING_FEATURES_AND_PROPERTIES_WILDCARD_REGEX, wildcardExpression);
}

/**
* Matches the passed {@code wildcardExpression} against wildcard regex
* {@code THING_FEATURES_WITH_ID_ONLY_WILDCARD_REGEX} and returns {@code true} if they match.
*
* @param wildcardExpression the wildcard expression that should be checked.
* @return {@code true} if the wildcardExpression matches the regex and false if not.
*/
public static boolean matchesThingFeaturesWithIdOnlyWildcard(final String wildcardExpression) {
return Pattern.matches(THING_FEATURES_WITH_ID_ONLY_WILDCARD_REGEX, wildcardExpression);
}

/**
* Matches the passed {@code wildcardExpression} against wildcard regex
* {@code THING_FEATURES_WITH_PROPERTIES_ONLY_WILDCARD_REGEX} and returns {@code true} if they match.
*
* @param wildcardExpression the wildcard expression that should be checked.
* @return {@code true} if the wildcardExpression matches the regex and false if not.
*/
public static boolean matchesThingFeaturesWithPropertiesOnlyWildcard(final String wildcardExpression) {
return Pattern.matches(THING_FEATURES_WITH_PROPERTIES_ONLY_WILDCARD_REGEX, wildcardExpression);
}

/**
* Matches the passed {@code wildcardExpression} against wildcard regex {@code FEATURES_WILDCARD_REGEX}
* and returns {@code true} if they match.
*
* @param wildcardExpression the wildcard expression that should be checked.
* @return {@code true} if the wildcardExpression matches the regex and false if not.
*/
public static boolean matchesFeaturesWildcard(final String wildcardExpression) {
return Pattern.matches(FEATURES_WILDCARD_REGEX, wildcardExpression);
}

/**
* Matches the passed {@code wildcardExpression} against wildcard regex {@code FEATURES_WITH_ID_ONLY_WILDCARD_REGEX}
* and returns {@code true} if they match.
*
* @param wildcardExpression the wildcard expression that should be checked.
* @return {@code true} if the wildcardExpression matches the regex and false if not.
*/
public static boolean matchesFeaturesWithIdOnlyWildcard(final String wildcardExpression) {
return Pattern.matches(FEATURES_WITH_ID_ONLY_WILDCARD_REGEX, wildcardExpression);
}

/**
* Matches the passed {@code wildcardExpression} against wildcard regex
* {@code FEATURES_WITH_PROPERTIES_ONLY_WILDCARD_REGEX} and returns {@code true} if they match.
*
* @param wildcardExpression the wildcard expression that should be checked.
* @return {@code true} if the wildcardExpression matches the regex and false if not.
*/
public static boolean matchesFeaturesWithPropertyOnlyWildcard(final String wildcardExpression) {
return Pattern.matches(FEATURES_WITH_PROPERTIES_ONLY_WILDCARD_REGEX, wildcardExpression);
}

/**
* Matches the passed {@code wildcardExpression} against wildcard regex {@code FEATURE_PROPERTY_WILDCARD_REGEX}
* and returns {@code true} if they match.
*
* @param wildcardExpression the wildcard expression that should be checked.
* @return {@code true} if the wildcardExpression matches the regex and false if not.
*/
public static boolean matchesFeaturePropertyWildcard(final String wildcardExpression) {
return Pattern.matches(FEATURE_PROPERTY_WILDCARD_REGEX, wildcardExpression);
}

/**
* Matches the passed {@code wildcardExpression} against wildcard regex {@code ATTRIBUTES_WILDCARD_REGEX}
* and returns {@code true} if they match.
*
* @param wildcardExpression the wildcard expression that should be checked.
* @return {@code true} if the wildcardExpression matches the regex and false if not.
*/
public static boolean matchesAttributesWildcard(final String wildcardExpression) {
return Pattern.matches(ATTRIBUTES_WILDCARD_REGEX, wildcardExpression);
}

/**
* Matches the passed {@code wildcardExpression} against wildcard regex {@code LEAF_WILDCARD_REGEX}
* and returns {@code true} if they match.
*
* @param wildcardExpression the wildcard expression that should be checked.
* @return {@code true} if the wildcardExpression matches the regex and false if not.
*/
public static boolean matchesLeafWildcard(final String wildcardExpression) {
return Pattern.matches(LEAF_WILDCARD_REGEX, wildcardExpression);
}
Expand Down

0 comments on commit c4b24ea

Please sign in to comment.