net.bytebuddy.utility.CompoundList Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of byte-buddy Show documentation
Show all versions of byte-buddy Show documentation
Byte Buddy is a Java library for creating Java classes at run time.
This artifact is a build of Byte Buddy with all ASM dependencies repackaged into its own name space.
package net.bytebuddy.utility;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/**
* Creates a list representation of two lists as a single, compound list.
*/
public class CompoundList {
/**
* A compound list cannot be created.
*/
private CompoundList() {
throw new UnsupportedOperationException("Cannot create a compound list");
}
/**
* Creates a list of a single element and another list.
*
* @param left The left element.
* @param right The right list.
* @param The type of the list's elements.
* @return A compound list representing the element and the list.
*/
public static List of(S left, List extends S> right) {
return of(Collections.singletonList(left), right);
}
/**
* Creates a list of a list and an element.
*
* @param left The left left.
* @param right The right element.
* @param The type of the list's elements.
* @return A compound list representing the element and the list.
*/
public static List of(List extends S> left, S right) {
return of(left, Collections.singletonList(right));
}
/**
* Creates a list of a left and right list.
*
* @param left The left list.
* @param right The right list.
* @param The type of the list's elements.
* @return A compound list representing the element and the list.
*/
public static List of(List extends S> left, List extends S> right) {
List list = new ArrayList(left.size() + right.size());
list.addAll(left);
list.addAll(right);
return list;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy