Java Code Examples for org.apache.commons.lang3.ArrayUtils.toArray()

The following are Jave code examples for showing how to use toArray() of the org.apache.commons.lang3.ArrayUtils class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: teiniker-lectures-configurationmanagement   File: ArrayExample.java   View Source Code Vote up 6 votes
public static void main(String[] args)
{
	String[] array = ArrayUtils.toArray("one", "two", "three");	
	System.out.println(ArrayUtils.toString(array));
	
	array = ArrayUtils.add(array, "four");
	System.out.println(ArrayUtils.toString(array));
	
	if(ArrayUtils.contains(array,"two"))
	{
		System.out.println("found \"two\" in the array.");
	}
	
	ArrayUtils.reverse(array);
	System.out.println(ArrayUtils.toString(array));
}
 
Example 2
Project: teiniker-lectures-configurationmanagement   File: ArrayExample.java   View Source Code Vote up 6 votes
public static void main(String[] args)
{
	String[] array = ArrayUtils.toArray("one", "two", "three");	
	System.out.println(ArrayUtils.toString(array));
	
	array = ArrayUtils.add(array, "four");
	System.out.println(ArrayUtils.toString(array));
	
	if(ArrayUtils.contains(array,"two"))
	{
		System.out.println("found \"two\" in the array.");
	}
	
	ArrayUtils.reverse(array);
	System.out.println(ArrayUtils.toString(array));
}
 
Example 3
Project: randomito-all   File: PostProcessorExecutor.java   View Source Code Vote up 5 votes
@SuppressWarnings("unchecked")
public Object postprocess(DefaultContext ctx) throws Exception {
    Object instance = ctx.getRef();
    if (instance == null) {
        return null;
    }
    if (excluded.contains(instance.getClass())) {
        return instance;
    }
    Field[] fields;
    if (ctx.getParent() == null) {
        fields = ArrayUtils.toArray(ctx.getField());
    } else {
        fields = ReflectionUtils.getDeclaredFields(instance.getClass(), true);
    }

    for (PostProcessor postprocessor : registry.values()) {
        for (Field field : fields) {
            if (!ReflectionUtils.makeFieldAccessible(field)) {
                continue;
            }
            Object o = field.get(instance);
            if (o == null) {
                continue;
            }
            Object postprocessed = postprocessor.process(ctx.createChild(instance, field), o);
            if (!Objects.equals(o, postprocessed)) {
                field.set(instance, postprocessed);
            }
        }

    }
    return instance;
}