本文整理了Java中org.apache.commons.collections.Factory.create()
方法的一些代码示例,展示了Factory.create()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Factory.create()
方法的具体详情如下:
包路径:org.apache.commons.collections.Factory
类名称:Factory
方法名:create
[英]Create a new object.
[中]创建一个新对象。
代码示例来源:origin: commons-collections/commons-collections
/**
* Transforms the input by ignoring the input and returning the result of
* calling the decorated factory.
*
* @param input the input object to transform
* @return the transformed result
*/
public Object transform(Object input) {
return iFactory.create();
}
代码示例来源:origin: wildfly/wildfly
/**
* Transforms the input by ignoring the input and returning the result of
* calling the decorated factory.
*
* @param input the input object to transform
* @return the transformed result
*/
public Object transform(Object input) {
return iFactory.create();
}
代码示例来源:origin: commons-collections/commons-collections
/**
* Creates a new instance of the map value Collection container
* using the factory.
* <p>
* This method can be overridden to perform your own processing
* instead of using the factory.
*
* @param size the collection size that is about to be added
* @return the new collection
*/
protected Collection createCollection(int size) {
return (Collection) collectionFactory.create();
}
代码示例来源:origin: wildfly/wildfly
/**
* Creates a new instance of the map value Collection container
* using the factory.
* <p>
* This method can be overridden to perform your own processing
* instead of using the factory.
*
* @param size the collection size that is about to be added
* @return the new collection
*/
protected Collection createCollection(int size) {
return (Collection) collectionFactory.create();
}
代码示例来源:origin: commons-collections/commons-collections
/**
* Transforms the input to result by cloning it.
*
* @param input the input object to transform
* @return the transformed result
*/
public Object transform(Object input) {
if (input == null) {
return null;
}
return PrototypeFactory.getInstance(input).create();
}
代码示例来源:origin: wildfly/wildfly
/**
* Transforms the input to result by cloning it.
*
* @param input the input object to transform
* @return the transformed result
*/
public Object transform(Object input) {
if (input == null) {
return null;
}
return PrototypeFactory.getInstance(input).create();
}
代码示例来源:origin: commons-collections/commons-collections
if (object == null) {
object = factory.create();
getList().set(index, object);
return object;
Object object = factory.create();
getList().add(object);
return object;
代码示例来源:origin: wildfly/wildfly
if (object == null) {
object = factory.create();
getList().set(index, object);
return object;
Object object = factory.create();
getList().add(object);
return object;
代码示例来源:origin: commons-collections/commons-collections
public void testInstantiateFactoryComplex() {
TimeZone.setDefault(TimeZone.getTimeZone("GMT"));
// 2nd Jan 1970
Factory factory = FactoryUtils.instantiateFactory(Date.class,
new Class[] {Integer.TYPE, Integer.TYPE, Integer.TYPE},
new Object[] {new Integer(70), new Integer(0), new Integer(2)});
assertNotNull(factory);
Object created = factory.create();
assertTrue(created instanceof Date);
// long time of 1 day (== 2nd Jan 1970)
assertEquals(new Date(1000 * 60 * 60 * 24), created);
}
代码示例来源:origin: commons-collections/commons-collections
public void testPrototypeFactoryPublicCloneMethod() throws Exception {
Date proto = new Date();
Factory factory = PrototypeFactory.getInstance(proto);
assertNotNull(factory);
Object created = factory.create();
assertTrue(proto != created);
assertEquals(proto, created);
// check serialisation works - if enabled
System.setProperty(FunctorUtils.UNSAFE_SERIALIZABLE_PROPERTY, "true");
try {
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
ObjectOutputStream out = new ObjectOutputStream(buffer);
out.writeObject(factory);
out.close();
ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray()));
Object dest = in.readObject();
in.close();
} finally {
System.setProperty(FunctorUtils.UNSAFE_SERIALIZABLE_PROPERTY, "false");
}
}
代码示例来源:origin: commons-collections/commons-collections
public void testPrototypeFactoryPublicSerialization() throws Exception {
Integer proto = new Integer(9);
Factory factory = FactoryUtils.prototypeFactory(proto);
assertNotNull(factory);
Object created = factory.create();
assertTrue(proto != created);
assertEquals(proto, created);
// check serialisation works - if enabled
System.setProperty(FunctorUtils.UNSAFE_SERIALIZABLE_PROPERTY, "true");
try {
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
ObjectOutputStream out = new ObjectOutputStream(buffer);
out.writeObject(factory);
out.close();
ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray()));
Object dest = in.readObject();
in.close();
} finally {
System.setProperty(FunctorUtils.UNSAFE_SERIALIZABLE_PROPERTY, "false");
}
}
代码示例来源:origin: commons-collections/commons-collections
public void testConstantFactoryConstant() {
Integer constant = new Integer(9);
Factory factory = FactoryUtils.constantFactory(constant);
assertNotNull(factory);
Object created = factory.create();
assertSame(constant, created);
}
代码示例来源:origin: commons-collections/commons-collections
public void testPrototypeFactoryPublicCopyConstructor() throws Exception {
Mock1 proto = new Mock1(6);
Factory factory = PrototypeFactory.getInstance(proto);
assertNotNull(factory);
Object created = factory.create();
assertTrue(proto != created);
assertEquals(proto, created);
// check serialisation works - if enabled
System.setProperty(FunctorUtils.UNSAFE_SERIALIZABLE_PROPERTY, "true");
try {
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
ObjectOutputStream out = new ObjectOutputStream(buffer);
try {
out.writeObject(factory);
} catch (NotSerializableException ex) {
out.close();
}
factory = FactoryUtils.prototypeFactory(new Mock2("S"));
buffer = new ByteArrayOutputStream();
out = new ObjectOutputStream(buffer);
out.writeObject(factory);
out.close();
ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray()));
Object dest = in.readObject();
in.close();
} finally {
System.setProperty(FunctorUtils.UNSAFE_SERIALIZABLE_PROPERTY, "false");
}
}
代码示例来源:origin: commons-collections/commons-collections
public void testConstantFactoryNull() {
Factory factory = FactoryUtils.constantFactory(null);
assertNotNull(factory);
Object created = factory.create();
assertNull(created);
}
代码示例来源:origin: commons-collections/commons-collections
public void testNullFactory() {
Factory factory = FactoryUtils.nullFactory();
assertNotNull(factory);
Object created = factory.create();
assertNull(created);
}
代码示例来源:origin: commons-collections/commons-collections
public void testInstantiateFactorySimple() {
Factory factory = FactoryUtils.instantiateFactory(Mock3.class);
assertNotNull(factory);
Object created = factory.create();
assertEquals(0, ((Mock3) created).getValue());
created = factory.create();
assertEquals(1, ((Mock3) created).getValue());
}
代码示例来源:origin: commons-collections/commons-collections
public void testPrototypeFactoryPublicSerializationError() {
Mock2 proto = new Mock2(new Object());
Factory factory = FactoryUtils.prototypeFactory(proto);
assertNotNull(factory);
try {
Object created = factory.create();
} catch (FunctorException ex) {
assertTrue(ex.getCause() instanceof IOException);
return;
}
fail();
}
代码示例来源:origin: commons-collections/commons-collections
public void testExceptionFactory() {
assertNotNull(FactoryUtils.exceptionFactory());
assertSame(FactoryUtils.exceptionFactory(), FactoryUtils.exceptionFactory());
try {
FactoryUtils.exceptionFactory().create();
} catch (FunctorException ex) {
try {
FactoryUtils.exceptionFactory().create();
} catch (FunctorException ex2) {
return;
}
}
fail();
}
代码示例来源:origin: org.apache.directory.api/api-ldap-client-all
/**
* Transforms the input to result by cloning it.
*
* @param input the input object to transform
* @return the transformed result
*/
public Object transform(Object input) {
if (input == null) {
return null;
}
return PrototypeFactory.getInstance(input).create();
}
代码示例来源:origin: org.opensingular/form-wicket
public static void buildFooter(BSContainer<?> footer, WicketBuildContext ctx, Factory createAddButton) {
if (canAddItems(ctx)) {
final TemplatePanel template = footer.newTemplateTag(tp -> createButtonMarkup(ctx));
template.add((Component) createAddButton.create());
} else {
footer.setVisible(false);
}
personalizeCSS(footer);
}
内容来源于网络,如有侵权,请联系作者删除!