Skip to content

Commit

Permalink
add new FieldType for fields with marked as special or hidden;
Browse files Browse the repository at this point in the history
Signed-off-by: Stefan Maute <stefan.maute@bosch.io>
  • Loading branch information
Stefan Maute committed Dec 2, 2021
1 parent 80d843f commit 6f92391
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@

import javax.annotation.concurrent.Immutable;

import org.eclipse.ditto.json.JsonField;
import org.eclipse.ditto.json.JsonFieldSelector;
import org.eclipse.ditto.json.JsonObject;
import org.eclipse.ditto.base.model.entity.id.EntityId;
import org.eclipse.ditto.base.model.entity.metadata.Metadata;
import org.eclipse.ditto.base.model.json.FieldType;
import org.eclipse.ditto.base.model.json.JsonSchemaVersion;
import org.eclipse.ditto.base.model.json.Jsonifiable;
import org.eclipse.ditto.json.JsonField;
import org.eclipse.ditto.json.JsonFieldSelector;
import org.eclipse.ditto.json.JsonObject;

/**
* Base type for top level entities.
Expand Down Expand Up @@ -79,9 +79,9 @@ public interface Entity<T extends Revision<T>> extends Jsonifiable.WithFieldSele
boolean isDeleted();

/**
* Returns all non hidden marked fields of this object.
* Returns all non-hidden marked fields of this object.
*
* @return a JSON object representation of this object including only non hidden marked fields.
* @return a JSON object representation of this object including only non-hidden marked fields.
*/
@Override
default JsonObject toJson() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,16 @@ public static Predicate<JsonField> regularOrSpecial() {
return FieldType.REGULAR.or(FieldType.SPECIAL);
}

/**
* Returns a Predicate for fields which are either {@link #SPECIAL} or {@link #HIDDEN}.
*
* @return the Predicate.
* @since 2.3.0.
*/
public static Predicate<JsonField> specialOrHidden() {
return FieldType.SPECIAL.or(FieldType.HIDDEN);
}

/**
* Returns a Predicate which returns {@code true} for all fields.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ public CharSequence subSequence(final int start, final int end) {
}

/**
* The string representation of this JSON pointer, i. e. all of its levels concatenated by {@literal "/"}. For
* The string representation of this JSON pointer, i.e. all of its levels concatenated by {@literal "/"}. For
* example if this pointer consists of the three levels {@code "foo"}, {@code "bar"} and {@code "baz"}, this method
* will return the string {@code "/foo/bar/baz"}. If this pointer #isEmpty(), this method will return the empty
* string {@code ""}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@
import javax.annotation.Nullable;
import javax.annotation.concurrent.Immutable;

import org.eclipse.ditto.base.model.entity.Entity;
import org.eclipse.ditto.base.model.json.FieldType;
import org.eclipse.ditto.base.model.json.JsonSchemaVersion;
import org.eclipse.ditto.json.JsonFactory;
import org.eclipse.ditto.json.JsonField;
import org.eclipse.ditto.json.JsonFieldDefinition;
import org.eclipse.ditto.json.JsonObject;
import org.eclipse.ditto.json.JsonPointer;
import org.eclipse.ditto.json.JsonValue;
import org.eclipse.ditto.base.model.entity.Entity;
import org.eclipse.ditto.base.model.json.FieldType;
import org.eclipse.ditto.base.model.json.JsonSchemaVersion;
import org.eclipse.ditto.policies.model.PolicyId;

/**
Expand Down Expand Up @@ -705,7 +705,8 @@ final class JsonFields {
* JSON field containing the Thing's Policy ID.
*/
public static final JsonFieldDefinition<String> POLICY_ID =
JsonFactory.newStringFieldDefinition("policyId", FieldType.REGULAR, JsonSchemaVersion.V_2);
JsonFactory.newStringFieldDefinition("policyId", FieldType.REGULAR,
JsonSchemaVersion.V_2);

/**
* JSON field containing the Thing's definition.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ public enum UpdateReason {
* The thing is indexed as part of a manual re-indexing.
*/
MANUAL_REINDEXING,
/**
* The thing is indexed as part of the automatic background sync.
*/
BACKGROUND_SYNC,
/**
* The thing was updated.
*/
THING_UPDATE,
/**
* The thing is indexed as part of the automatic background sync.
*/
BACKGROUND_SYNC,
/**
* Reason not known.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ private static EnforcementCacheKey getPolicyCacheKey(final PolicyId policyId) {

/**
* Decide whether to reload an enforcer entry.
* An entry should be reload if it is out-of-date, nonexistent, or corresponds to a nonexistent entity.
* An entry should be reloaded if it is out-of-date, nonexistent, or corresponds to a nonexistent entity.
*
* @param entry the enforcer cache entry
* @param metadata the metadata
Expand Down

0 comments on commit 6f92391

Please sign in to comment.