@SuppressWarnings("unchecked") public Installer getInstaller(final String implClassName) { try { return ObjectExtensions.asT(InstanceUtil.createInstance(implClassName)); } catch (final UnavailableClassException e) { return null; } }
/** * Automatically flattens any {@link List}s, recursively (depth-first) if * necessary. */ public void addFixture(final Object fixture) { if (fixture instanceof List) { final List<Object> fixtureList = ObjectExtensions.asListT(fixture, Object.class); for (final Object eachFixture : fixtureList) { addFixture(eachFixture); } } else { fixtures.add(fixture); } }
public MapInvocationHandler(final C collectionToProxy, final String collectionName, final DomainObjectInvocationHandler<T> handler, final OneToManyAssociation otma) { super(collectionToProxy, collectionName, handler, otma); try { intercept(ObjectExtensions.getMethod(collectionToProxy, "containsKey", Object.class)); intercept(ObjectExtensions.getMethod(collectionToProxy, "containsValue", Object.class)); intercept(ObjectExtensions.getMethod(collectionToProxy, "size")); intercept(ObjectExtensions.getMethod(collectionToProxy, "isEmpty")); veto(ObjectExtensions.getMethod(collectionToProxy, "put", Object.class, Object.class)); veto(ObjectExtensions.getMethod(collectionToProxy, "remove", Object.class)); veto(ObjectExtensions.getMethod(collectionToProxy, "putAll", Map.class)); veto(ObjectExtensions.getMethod(collectionToProxy, "clear")); } catch (final NoSuchMethodException e) { // ///CLOVER:OFF throw new RuntimeException("A Collection method could not be found: " + e.getMessage()); // ///CLOVER:ON } }
public CollectionInvocationHandler( final R collectionToProxy, final String collectionName, final DomainObjectInvocationHandler<T> handler, final OneToManyAssociation otma) { super(collectionToProxy, collectionName, handler, otma); try { intercept(ObjectExtensions.getMethod(collectionToProxy, "contains", Object.class)); intercept(ObjectExtensions.getMethod(collectionToProxy, "size")); intercept(ObjectExtensions.getMethod(collectionToProxy, "isEmpty")); if (collectionToProxy instanceof List) { intercept(ObjectExtensions.getMethod(collectionToProxy, "get", int.class)); } veto(ObjectExtensions.getMethod(collectionToProxy, "add", Object.class)); veto(ObjectExtensions.getMethod(collectionToProxy, "remove", Object.class)); veto(ObjectExtensions.getMethod(collectionToProxy, "addAll", Collection.class)); veto(ObjectExtensions.getMethod(collectionToProxy, "removeAll", Collection.class)); veto(ObjectExtensions.getMethod(collectionToProxy, "retainAll", Collection.class)); veto(ObjectExtensions.getMethod(collectionToProxy, "clear")); } catch (final NoSuchMethodException e) { // ///CLOVER:OFF throw new RuntimeException("A Collection method could not be found: " + e.getMessage()); // ///CLOVER:ON } }
@SuppressWarnings("unused") private void copyDeploymentTypeIntoInitParams(final WebAppContext context) { Map<String, String> initParams = context.getInitParams(); Map<String, String> convertedInitParams = ObjectExtensions.asT(initParams); initParams.clear(); initParams.putAll(convertedInitParams); }