forked from phoedos/pmd
Improve builders interface
This commit is contained in:
@ -4,7 +4,9 @@
|
||||
|
||||
package net.sourceforge.pmd.properties.builders;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import net.sourceforge.pmd.properties.MultiValuePropertyDescriptor;
|
||||
@ -36,8 +38,8 @@ public abstract class MultiValuePropertyBuilder<V, T extends MultiValuePropertyB
|
||||
* @return The same builder
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public T defaultValues(List<V> val) {
|
||||
this.defaultValues = val;
|
||||
public T defaultValues(Collection<? extends V> val) {
|
||||
this.defaultValues = new ArrayList<>(val);
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
|
@ -5,6 +5,7 @@
|
||||
package net.sourceforge.pmd.properties.builders;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
|
||||
|
||||
/**
|
||||
@ -22,12 +23,35 @@ public abstract class SinglePackagedPropertyBuilder<V, T extends SinglePackagedP
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Specify the allowed package prefixes.
|
||||
*
|
||||
* @param packs The package prefixes
|
||||
*
|
||||
* @return The same builder
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public T legalPackageNames(String[] packs) {
|
||||
public T legalPackageNames(String... packs) {
|
||||
if (packs != null) {
|
||||
this.legalPackageNames = Arrays.copyOf(packs, packs.length);
|
||||
}
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Specify the allowed package prefixes.
|
||||
*
|
||||
* @param packs The package prefixes
|
||||
*
|
||||
* @return The same builder
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public T legalPackageNames(Collection<String> packs) {
|
||||
if (packs != null) {
|
||||
this.legalPackageNames = packs.toArray(new String[0]);
|
||||
}
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user