@Test @DisplayName("not accept null `Visibility` values") void notAcceptNulls() { Optional<EntityVisibility> value = EntityVisibility.of(Password.class); assertThat(value).isPresent(); EntityVisibility instance = value.get(); new NullPointerTester() .testAllPublicInstanceMethods(instance); }
public static Optional<EntityVisibility> of(Class<? extends EntityState> stateClass) { checkNotNull(stateClass); if (Event.class.equals(stateClass)) { return Optional.of(new EntityVisibility(NONE)); } if (!GeneratedMessageV3.class.isAssignableFrom(stateClass)) { return Optional.empty(); } Descriptor descriptor = TypeName.of(stateClass) .messageDescriptor(); Optional<EntityOption> option = EntityStateOption.valueOf(descriptor); if(!option.isPresent()) { return Optional.empty(); } EntityOption entityOption = option.get(); Visibility visibility = entityOption.getVisibility(); if (visibility == DEFAULT) { Kind kind = entityOption.getKind(); visibility = kind == PROJECTION ? FULL : NONE; } EntityVisibility result = new EntityVisibility(visibility); return Optional.of(result); }
EntityVisibility implements Serializable { public static Optional<EntityVisibility> of(Class<? extends EntityState> stateClass) { checkNotNull(stateClass); if (Event.class.equals(stateClass)) { return Optional.of(new EntityVisibility(NONE)); } if (!GeneratedMessageV3.class.isAssignableFrom(stateClass)) { return Optional.empty(); } Descriptor descriptor = TypeName.of(stateClass) .messageDescriptor(); Optional<EntityOption> option = EntityStateOption.valueOf(descriptor); if(!option.isPresent()) { return Optional.empty(); } EntityOption entityOption = option.get(); Visibility visibility = entityOption.getVisibility(); if (visibility == DEFAULT) { Kind kind = entityOption.getKind(); visibility = kind == PROJECTION ? FULL : NONE; } EntityVisibility result = new EntityVisibility(visibility); return Optional.of(result); } }
EntityVisibility implements Serializable { public static Optional<EntityVisibility> of(Class<? extends EntityState> stateClass) { checkNotNull(stateClass); if (Event.class.equals(stateClass)) { return Optional.of(new EntityVisibility(NONE)); } if (!GeneratedMessageV3.class.isAssignableFrom(stateClass)) { return Optional.empty(); } Descriptor descriptor = TypeName.of(stateClass) .messageDescriptor(); Optional<EntityOption> option = EntityStateOption.valueOf(descriptor); if(!option.isPresent()) { return Optional.empty(); } EntityOption entityOption = option.get(); Visibility visibility = entityOption.getVisibility(); if (visibility == DEFAULT) { Kind kind = entityOption.getKind(); visibility = kind == PROJECTION ? FULL : NONE; } EntityVisibility result = new EntityVisibility(visibility); return Optional.of(result); } private  EntityVisibility(Visibility value); }
EntityVisibility implements Serializable { public static Optional<EntityVisibility> of(Class<? extends EntityState> stateClass) { checkNotNull(stateClass); if (Event.class.equals(stateClass)) { return Optional.of(new EntityVisibility(NONE)); } if (!GeneratedMessageV3.class.isAssignableFrom(stateClass)) { return Optional.empty(); } Descriptor descriptor = TypeName.of(stateClass) .messageDescriptor(); Optional<EntityOption> option = EntityStateOption.valueOf(descriptor); if(!option.isPresent()) { return Optional.empty(); } EntityOption entityOption = option.get(); Visibility visibility = entityOption.getVisibility(); if (visibility == DEFAULT) { Kind kind = entityOption.getKind(); visibility = kind == PROJECTION ? FULL : NONE; } EntityVisibility result = new EntityVisibility(visibility); return Optional.of(result); } private  EntityVisibility(Visibility value); static Optional<EntityVisibility> of(Class<? extends EntityState> stateClass); boolean canSubscribe(); boolean canQuery(); boolean isNotNone(); boolean is(Visibility visibility); boolean isAsLeast(Visibility visibility); @Override String toString(); }
EntityVisibility implements Serializable { public static Optional<EntityVisibility> of(Class<? extends EntityState> stateClass) { checkNotNull(stateClass); if (Event.class.equals(stateClass)) { return Optional.of(new EntityVisibility(NONE)); } if (!GeneratedMessageV3.class.isAssignableFrom(stateClass)) { return Optional.empty(); } Descriptor descriptor = TypeName.of(stateClass) .messageDescriptor(); Optional<EntityOption> option = EntityStateOption.valueOf(descriptor); if(!option.isPresent()) { return Optional.empty(); } EntityOption entityOption = option.get(); Visibility visibility = entityOption.getVisibility(); if (visibility == DEFAULT) { Kind kind = entityOption.getKind(); visibility = kind == PROJECTION ? FULL : NONE; } EntityVisibility result = new EntityVisibility(visibility); return Optional.of(result); } private  EntityVisibility(Visibility value); static Optional<EntityVisibility> of(Class<? extends EntityState> stateClass); boolean canSubscribe(); boolean canQuery(); boolean isNotNone(); boolean is(Visibility visibility); boolean isAsLeast(Visibility visibility); @Override String toString();  }