public VeganPolicy applyPolicy(@Optional @NullSafe VeganPolicy policy) { return policy; }
if (nullSafe != null) { MetadataType nullSafeType; if (Object.class.equals(nullSafe.defaultImplementingType())) { nullSafeType = objectField.getValue(); } else { nullSafeType = new BaseTypeBuilder(JAVA).objectType() .with(new TypeIdAnnotation(nullSafe.defaultImplementingType().getName())) .build();
if (nullSafe != null) { MetadataType nullSafeType; if (Object.class.equals(nullSafe.defaultImplementingType())) { nullSafeType = objectField.getValue(); } else { nullSafeType = new BaseTypeBuilder(JAVA).objectType() .with(new TypeIdAnnotation(nullSafe.defaultImplementingType().getName())) .build();
public Map<String, String> addVeganProductsDescriptions(@Optional @NullSafe Map<String, String> productDescription) { return productDescription; }
public List<String> registerVeganProducts(@Optional @NullSafe List<String> products) { return products; }
public List<Map<String, String>> tryToEatThisListOfMaps(@Optional @NullSafe @Content List<Map<String, String>> foods) { if (foods != null) { return foods; } throw new IllegalArgumentException("I CAN'T EAT THAT TYPE, IS IMPOSSIBLE!"); }
public class NullSafeParameterGroup { @Parameter @Optional @NullSafe private NullSafePojo nullSafePojo; public NullSafePojo getNullSafePojo() { return nullSafePojo; } public void setNullSafePojo(NullSafePojo nullSafePojo) { this.nullSafePojo = nullSafePojo; } }
@OutputResolver(output = FruitMetadataResolver.class) public FarmedFood getProduction(@Optional @NullSafe(defaultImplementingType = HealthyFood.class) FarmedFood food) { return food; }
public class NullSafeParameterGroupShowInDsl { @Parameter @Optional @NullSafe private NullSafePojo nullSafePojoShowInDsl; public NullSafePojo getNullSafePojoShowInDsl() { return nullSafePojoShowInDsl; } public void setNullSafePojoShowInDsl(NullSafePojo nullSafePojoShowInDsl) { this.nullSafePojoShowInDsl = nullSafePojoShowInDsl; } }
@TypeDsl(allowTopLevelDefinition = true) public class GroupedFood { @Parameter @Optional @NullSafe(defaultImplementingType = RottenFood.class) private FarmedFood food; public FarmedFood getFood() { return food; } public void setFood(FarmedFood food) { this.food = food; } }
@OutputResolver(output = FruitMetadataResolver.class) public List<FarmedFood> consumingGroupedFood(@ParameterGroup(name = "As Group") GroupedFood groupedFood, @Optional @NullSafe GroupedFood pojoGroupedFood) { return Arrays.asList(groupedFood.getFood(), pojoGroupedFood.getFood()); }
@TypeDsl(allowTopLevelDefinition = true) public class HealthyFood implements FarmedFood { @Parameter @NullSafe @Optional private TasteProfile tasteProfile; @Override public boolean canBeEaten() { return true; } public TasteProfile getTasteProfile() { return tasteProfile; } public static class TasteProfile { @Parameter @Optional(defaultValue = "false") private boolean tasty; public boolean isTasty() { return tasty; } } }
@Alias("grape-connection") public class GrapeConnProvider implements ConnectionProvider<VeganPolicy> { @NullSafe @Parameter @Optional public VeganPolicy veganPolicy; @Override public VeganPolicy connect() throws ConnectionException { return veganPolicy; } @Override public void disconnect(VeganPolicy connection) { } @Override public ConnectionValidationResult validate(VeganPolicy connection) { return success(); } }
private static class AbstractNullSafeTypeWithAbstractOverride { @Parameter @NullSafe(defaultImplementingType = AbstractChildPojo.class) @Optional private ParentPojo pojo; }
private static class AbstractNullSafeTypeWithoutOverride { @Parameter @NullSafe @Optional private ParentPojo pojo; }
private static class DictionaryWithDefaultImplementingType { @Parameter @NullSafe(defaultImplementingType = LinkedList.class) @Optional private Map<String, String> strings; }
private static class BasicTypeWithNullSafe { @Parameter @NullSafe @Optional private String bla; }
private static class ImplementingTypeNotAssignable { @Parameter @NullSafe(defaultImplementingType = UnrelatedPojo.class) @Optional private ParentPojo pojo; }
public void setSecureCage(@Optional @NullSafe List<String> providers, String user, String pass, AuthenticationHandler authHandler) throws SecurityException, SecurityProviderNotFoundException, UnknownAuthenticationTypeException { authHandler.setAuthentication(providers, authHandler.createAuthentication(authHandler.createCredentialsBuilder() .withUsername(user) .withPassword(pass.toCharArray()) .build())); }