/** returns base, superclasses, then interfaces */ public static List<Class<?>> getAllAssignableTypes(Class<?> base) { return getAllAssignableTypes(base, new Predicate<Class<?>>() { @Override public boolean apply(Class<?> it) { return (it != Object.class) && (it != GroovyObject.class); } }); } /**
@Override public <T> T coerce(Object input, Class<T> type) { return TypeCoercions.coerce(input, type); } @Override public <T> Maybe<T> tryCoerce(Object input, Class<T> type) {
@Override public <T> Maybe<T> tryCoerce(Object input, Class<T> type) { return TypeCoercions.tryCoerce(input, type); } @Override public <T> Maybe<T> tryCoerce(Object input, TypeToken<T> type) {
/** * Placement strategy for Docker containers in host clusters. */ public interface DockerAwarePlacementStrategy extends HasShortName { @SetFromFlag("infrastructure") ConfigKey<DockerInfrastructure> DOCKER_INFRASTRUCTURE = DockerVirtualLocation.INFRASTRUCTURE; DockerInfrastructure getDockerInfrastructure(); /** * Filters a list of {@link DockerHostLocation locations} to determine if the given {@link Entity} can be * deployed into a new container there. */ List<DockerHostLocation> filterLocations(List<DockerHostLocation> locations, Entity context); }
@Override protected CatalogItemDtoAbstract<T, SpecT> configure(Map<?, ?> flags) { FlagUtils.setFieldsFromFlags(flags, this); return this; }
public static class MyLocation extends AbstractLocation { public static final ConfigKey<String> MY_CONFIG = ConfigKeys.newStringConfigKey("mylocation.myconfig"); @SetFromFlag("myconfigflagname") public static final ConfigKey<String> MY_CONFIG_WITH_FLAGNAME = ConfigKeys.newStringConfigKey("mylocation.myconfigwithflagname"); public static final ConfigKey<String> MY_CONFIG_WITH_DEFAULT = ConfigKeys.newStringConfigKey("mylocation.myconfigwithdefault", "", "mydefault"); }
@SuppressWarnings("unchecked") protected <T> T coerce(Object value, Class<T> type) { if (type==null || value==null) return (T) value; return TypeCoercions.coerce(value, type); }
public static class MyChildLocation extends AbstractLocation { public static final ConfigKey<String> MY_CHILD_CONFIG = ConfigKeys.newStringConfigKey("mychildlocation.myconfig"); @SetFromFlag("mychildconfigflagname") public static final ConfigKey<String> MY_CHILD_CONFIG_WITH_FLAGNAME = ConfigKeys.newStringConfigKey("mychildlocation.myconfigwithflagname"); }
public static class LocationWithOverriddenId extends ConcreteLocation { @SetFromFlag String overriddenId; public LocationWithOverriddenId() { } public String getId() { return overriddenId; } }
public static class Foo { @SetFromFlag int w; @SetFromFlag(immutable=true) private int x; @SetFromFlag("y") public int yNotY; }
public static class WithImmutableNonNullableObject { @SetFromFlag Object a; @SetFromFlag(immutable=true, nullable=false) public Object b; }
public static class MyChildEntity extends AbstractEntity { public static final ConfigKey<String> MY_CHILD_CONFIG = ConfigKeys.newStringConfigKey("mychildentity.myconfig"); @SetFromFlag("mychildconfigflagname") public static final ConfigKey<String> MY_CHILD_CONFIG_WITH_FLAGNAME = ConfigKeys.newStringConfigKey("mychildentity.myconfigwithflagname"); }
public static class MyPolicy extends AbstractPolicy { public static final BasicConfigKey<String> CONF1 = new BasicConfigKey<String>(String.class, "testpolicy.conf1", "my descr, conf1", "defaultval1"); public static final BasicConfigKey<Integer> CONF2 = new BasicConfigKey<Integer>(Integer.class, "testpolicy.conf2", "my descr, conf2", 2); @SetFromFlag public String myfield; }
public static class MyEnricher extends AbstractEnricher { public static final BasicConfigKey<String> CONF1 = new BasicConfigKey<String>(String.class, "testenricher.conf1", "my descr, conf1", "defaultval1"); public static final BasicConfigKey<Integer> CONF2 = new BasicConfigKey<Integer>(Integer.class, "testenricher.conf2", "my descr, conf2", 2); @SetFromFlag public String myfield; } }
public static class ConcreteLocation extends AbstractLocation { @SetFromFlag(defaultVal="mydefault") String myfield; public ConcreteLocation() { super(); } public ConcreteLocation(Map<?,?> properties) { super(properties); } }
public static class WithSpecialFieldTypes { @SetFromFlag Set<?> set; @SetFromFlag InetAddress inet; }
public static class MyOldStyleLocation extends AbstractLocation { @SetFromFlag String myfield; public MyOldStyleLocation(Map<?,?> flags) { super(flags); } }
public static class MyOldStyleEntity extends AbstractEntity { @SetFromFlag("confName") public static final ConfigKey<String> CONF_NAME = TestEntity.CONF_NAME; @SuppressWarnings("deprecation") public MyOldStyleEntity(Map<?,?> flags, Entity parent) { super(flags, parent); } }
private static class ConcreteLocation extends AbstractLocation { @SetFromFlag(defaultVal="mydefault") String myfield; public ConcreteLocation() { super(); } public ConcreteLocation(Map properties) { super(properties); } }
public static class MyEntity extends AbstractEntity { public static final ConfigKey<String> MY_CONFIG = ConfigKeys.newStringConfigKey("myentity.myconfig"); @SetFromFlag("myconfigflagname") public static final ConfigKey<String> MY_CONFIG_WITH_FLAGNAME = ConfigKeys.newStringConfigKey("myentity.myconfigwithflagname"); @Override public void init() { super.init(); // Just calling this to prove we can! When config() was changed to return BasicConfigurationSupport, // it broke because BasicConfigurationSupport was private. config().getLocalBag(); } }