/** * Checks that the object is an instance of the specified Class and then returns the object cast to the specified Class * * @param <C> the class type * @param argument Value * @param expectedClass Class * @param name The name of the argument * @return value cast to the specified Class * @throws IllegalArgumentException If value is not an instance of theClass. */ // due to cast in return public static <C> C getInstanceOf( Object argument, Class<C> expectedClass, String name ) { isInstanceOf(argument, expectedClass, name); return expectedClass.cast(argument); }
/** * Determine whether this component has changed with respect to the supplied component. This method basically checks all * attributes, whereas {@link #equals(Object) equals} only checks the {@link #getClass() type} and {@link #getName()}. * * @param component the component to be compared with this one * @return true if this componet and the supplied component have some changes, or false if they are exactly equivalent * @throws IllegalArgumentException if the supplied component reference is null or is not the same {@link #getClass() type} as * this object */ public boolean hasChanged( ComponentConfig component ) { CheckArg.isNotNull(component, "component"); CheckArg.isInstanceOf(component, this.getClass(), "component"); if (!this.getName().equalsIgnoreCase(component.getName())) return true; if (!this.getDescription().equals(component.getDescription())) return true; if (!this.getComponentClassname().equals(component.getComponentClassname())) return true; if (!this.getComponentClasspath().equals(component.getComponentClasspath())) return true; return false; }