All Downloads are FREE. Search and download functionalities are using the official Maven repository.
Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
org.picocontainer.injectors.NamedMethodInjector Maven / Gradle / Ivy
/*****************************************************************************
* Copyright (C) PicoContainer Organization. All rights reserved. *
* ------------------------------------------------------------------------- *
* The software in this package is published under the terms of the BSD *
* style license a copy of which has been included with this distribution in *
* the LICENSE.txt file. *
* *
* Original code by *
*****************************************************************************/
package org.picocontainer.injectors;
import org.picocontainer.ComponentMonitor;
import org.picocontainer.NameBinding;
import org.picocontainer.Parameter;
import org.picocontainer.PicoContainer;
import java.lang.reflect.AccessibleObject;
import java.lang.reflect.Method;
import java.lang.reflect.Type;
import java.util.Set;
@SuppressWarnings("serial")
public class NamedMethodInjector extends SetterInjector {
public NamedMethodInjector(Object key,
Class> impl,
Parameter[] parameters,
ComponentMonitor monitor,
boolean optional) {
this(key, impl, parameters, monitor, "set", optional);
}
public NamedMethodInjector(Object key,
Class> impl,
Parameter[] parameters,
ComponentMonitor monitor) {
this(key, impl, parameters, monitor, "set", true);
}
public NamedMethodInjector(Object key,
Class> impl,
Parameter[] parameters,
ComponentMonitor monitor,
String prefix) {
this(key, impl, parameters, monitor, prefix, true);
}
public NamedMethodInjector(Object key,
Class> impl,
Parameter[] parameters,
ComponentMonitor monitor,
String prefix,
boolean optional) {
super(key, impl, parameters, monitor, prefix, "", optional, true);
}
@Override
protected NameBinding makeParameterNameImpl(final AccessibleObject member) {
return new NameBinding() {
public String getName() {
String name = ((Method)member).getName().substring(prefix.length()); // string off 'set' or chosen prefix
return name.substring(0,1).toLowerCase() + name.substring(1); // change "SomeThing" to "someThing"
}
};
}
@Override
public String getDescriptor() {
return "NamedMethodInjection";
}
}