/** * For injection; will {@link #defaultRandomCodeGeneratorIfNecessary() default} otherwise. */ public void setRandomCodeGenerator(final RandomCodeGenerator randomCodeGenerator) { ensureThatArg(randomCodeGenerator, is(notNullValue()), "randomCodeGenerator cannot be null"); this.randomCodeGenerator = randomCodeGenerator; }
private void ensureNotInitialized() { ensureThatState(initialized, is(false)); }
/** * To ensure that the current state of this object (instance fields) is correct. * * @see #ensureThatArg(Object, Matcher) * @see #ensureThatContext(Object, Matcher) * @see #ensureThatState(Object, Matcher, String) * * @throws IllegalStateException if matcher does not {@link Matcher#matches(Object) match}. */ public static <T> T ensureThatState(final T field, final Matcher<T> matcher) { if (!matcher.matches(field)) { throw new IllegalStateException("illegal argument, expected: " + descriptionOf(matcher)); } return field; }
public ObjectResolveAndObjectChangedEnhancerAbstract( final ObjectResolver objectResolver, final ObjectChanger objectChanger, final SpecificationLoader specificationLoader) { ensureThatArg(objectResolver, is(notNullValue())); ensureThatArg(objectChanger, is(notNullValue())); ensureThatArg(specificationLoader, is(notNullValue())); this.objectResolver = objectResolver; this.objectChanger = objectChanger; this.specificationLoader = specificationLoader; }
private void ensureInitialized() { ensureThatState(initialized, is(true)); }
/** * To ensure that the current state of this object (instance fields) is correct. * * @see #ensureThatArg(Object, Matcher) * @see #ensureThatContext(Object, Matcher) * @see #ensureThatState(Object, Matcher, String) * * @throws IllegalStateException if matcher does not {@link Matcher#matches(Object) match}. */ public static <T> T ensureThatState(final T field, final Matcher<T> matcher) { if (!matcher.matches(field)) { throw new IllegalStateException("illegal argument, expected: " + descriptionOf(matcher)); } return field; }
/** * Optionally specify the {@link TemplateImageLoader}. * * <p> * It will otherwise be {@link NakedObjectsSystemDefault#obtainTemplateImageLoader(DeploymentType) defaulted}. */ public void setTemplateImageLoader(final TemplateImageLoader templateImageLoader) { ensureThatArg(templateImageLoader, is(notNullValue()), "template Image Loader may not be set to null"); this.templateImageLoader = templateImageLoader; }
public void init() { ensureThatState(specificationLoader, is(notNullValue())); }
/** * To ensure that the provided argument is correct. * * @see #ensureThatArg(Object, Matcher,State) * @see #ensureThatState(Object, Matcher, String) * @see #ensureThatContext(Object, Matcher) * * @throws IllegalArgumentException if matcher does not {@link Matcher#matches(Object) match}. */ public static <T> T ensureThatArg(final T object, final Matcher<T> matcher) { if (!matcher.matches(object)) { throw new IllegalArgumentException( "illegal argument, expected: " + descriptionOf(matcher)); } return object; }
public void setReflector(final NakedObjectReflector reflector) { ensureThatArg(reflector, is(notNullValue()), "reflector may not be set to null"); this.reflector = reflector; }
public void open() { ensureThatState(session, is(notNullValue()), "session is required"); }
/** * To ensure that the provided argument is correct. * * @see #ensureThatArg(Object, Matcher,State) * @see #ensureThatState(Object, Matcher, String) * @see #ensureThatContext(Object, Matcher) * * @throws IllegalArgumentException if matcher does not {@link Matcher#matches(Object) match}. */ public static <T> T ensureThatArg(final T object, final Matcher<T> matcher) { if (!matcher.matches(object)) { throw new IllegalArgumentException( "illegal argument, expected: " + descriptionOf(matcher)); } return object; }
/** * Construct a new lazy stream based off the given provider. * * @param provider * the input stream provider. Must not be <code>null</code>. */ public LazyInputStream(InputStreamProvider provider) { Ensure.ensureThatArg(provider, is(not(nullValue()))); this.provider = provider; }
public void init() { ensureThatState(specificationLoader, is(notNullValue())); }
/** * To ensure that the current context (<tt>NakedObjectsContext</tt>) is correct. * * @see #ensureThatArg(Object, Matcher) * @see #ensureThatState(Object, Matcher) * @see #ensureThatContext(Object, Matcher, String) * * @throws IllegalThreadStateException if matcher does not {@link Matcher#matches(Object) match}. */ public static <T> T ensureThatContext(final T contextProperty, final Matcher<T> matcher) { if (!matcher.matches(contextProperty)) { throw new IllegalThreadStateException("illegal argument, expected: " + descriptionOf(matcher)); } return contextProperty; }
public ProxyAuthenticator( NakedObjectConfiguration configuration, ServerFacade serverFacade, ObjectEncoderDecoder encoderDecoder) { super(configuration); Ensure.ensureThatArg(serverFacade, is(not(nullValue()))); Ensure.ensureThatArg(encoderDecoder, is(not(nullValue()))); this.serverFacade = serverFacade; this.encoderDecoder = encoderDecoder; }
public void init() { ensureThatState(specificationLoader, is(notNullValue())); }
/** * To ensure that the current context (<tt>NakedObjectsContext</tt>) is correct. * * @see #ensureThatArg(Object, Matcher) * @see #ensureThatState(Object, Matcher) * @see #ensureThatContext(Object, Matcher, String) * * @throws IllegalThreadStateException if matcher does not {@link Matcher#matches(Object) match}. */ public static <T> T ensureThatContext(final T contextProperty, final Matcher<T> matcher) { if (!matcher.matches(contextProperty)) { throw new IllegalThreadStateException("illegal argument, expected: " + descriptionOf(matcher)); } return contextProperty; }
protected void setOid(final Oid oid) { Ensure.ensureThatArg(oid, is(notNullValue())); this.oid = oid; }
public FacetProcessor( final NakedObjectConfiguration configuration, final SpecificationLoader specificationLoader, final CollectionTypeRegistry collectionTypeRegistry, final ProgrammingModelFacets programmingModelFacets) { ensureThatState(configuration, is(notNullValue())); ensureThatState(collectionTypeRegistry, is(notNullValue())); ensureThatState(programmingModelFacets, is(notNullValue())); ensureThatState(specificationLoader, is(notNullValue())); this.configuration = configuration; this.specificationLoader = specificationLoader; this.programmingModelFacets = programmingModelFacets; this.collectionTypeRegistry = collectionTypeRegistry; }