本文整理汇总了Java中com.beust.jcommander.internal.Lists类的典型用法代码示例。如果您正苦于以下问题:Java Lists类的具体用法?Java Lists怎么用?Java Lists使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Lists类属于com.beust.jcommander.internal包,在下文中一共展示了Lists类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: readFile
import com.beust.jcommander.internal.Lists; //导入依赖的package包/类
/**
* Reads the file specified by filename and returns the file content as a string.
* End of lines are replaced by a space.
*
* @param fileName the command line filename
* @return the file content as a string.
*/
private List<String> readFile(String fileName) {
List<String> result = Lists.newArrayList();
try (BufferedReader bufRead = Files.newBufferedReader(Paths.get(fileName), options.atFileCharset)) {
String line;
// Read through file one line at time. Print line # and line
while ((line = bufRead.readLine()) != null) {
// Allow empty lines and # comments in these at files
if (line.length() > 0 && !line.trim().startsWith("#")) {
result.add(line);
}
}
} catch (IOException e) {
throw new ParameterException("Could not read file " + fileName + ": " + e);
}
return result;
}
示例2: getMainParameter
import com.beust.jcommander.internal.Lists; //导入依赖的package包/类
/**
* @return the field that's meant to receive all the parameters that are not options.
*
* @param arg the arg that we're about to add (only passed here to output a meaningful
* error message).
*/
private List<?> getMainParameter(String arg) {
if (mainParameter == null) {
throw new ParameterException(
"Was passed main parameter '" + arg + "' but no main parameter was defined in your arg class");
}
List<?> result = (List<?>) mainParameter.get(mainParameterObject);
if (result == null) {
result = Lists.newArrayList();
if (!List.class.isAssignableFrom(mainParameter.getType())) {
throw new ParameterException("Main parameter field " + mainParameter
+ " needs to be of type List, not " + mainParameter.getType());
}
mainParameter.set(mainParameterObject, result);
}
if (firstTimeMainParameter) {
result.clear();
firstTimeMainParameter = false;
}
return result;
}
示例3: dexPerClassFileWithDesugaring
import com.beust.jcommander.internal.Lists; //导入依赖的package包/类
@Test
public void dexPerClassFileWithDesugaring() throws Throwable {
String testName = "dexPerClassFileWithDesugaring";
String testPackage = "lambdadesugaringnplus";
String mainClass = "LambdasWithStaticAndDefaultMethods";
Path inputJarFile = Paths.get(EXAMPLE_DIR, testPackage + JAR_EXTENSION);
D8IncrementalTestRunner test = test(testName, testPackage, mainClass);
test.withInterfaceMethodDesugaring(OffOrAuto.Auto);
Resource mergedFromCompiledSeparately =
test.mergeClassFiles(Lists.newArrayList(
test.compileClassesSeparately(inputJarFile).values()), null);
Resource mergedFromCompiledTogether =
test.mergeClassFiles(Lists.newArrayList(
test.compileClassesTogether(inputJarFile, null).values()), null);
Assert.assertArrayEquals(
readFromResource(mergedFromCompiledSeparately),
readFromResource(mergedFromCompiledTogether));
}
示例4: getSign
import com.beust.jcommander.internal.Lists; //导入依赖的package包/类
/**
* 签名算法
*
* @param o 要参与签名的数据对象
* @return 签名
* @throws IllegalAccessException
*/
public static String getSign(Object o, String key) throws IllegalAccessException {
List<String> list = Lists.newArrayList();
Class cls = o.getClass();
Field[] fields = cls.getDeclaredFields();
for (Field f : fields) {
f.setAccessible(true);
if (f.get(o) != null && f.get(o) != "") {
list.add(f.getName() + "=" + f.get(o) + "&");
}
}
int size = list.size();
String[] arrayToSort = list.toArray(new String[size]);
Arrays.sort(arrayToSort, String.CASE_INSENSITIVE_ORDER);
StringBuilder sb = new StringBuilder();
for (int i = 0; i < size; i++) {
sb.append(arrayToSort[i]);
}
String result = sb.toString();
result += "key=" + key;
//log.log("Sign Before MD5:" + result);
result = md5(result).toUpperCase();
//Util.log("Sign Result:" + result);
return result;
}
示例5: createStringUrl
import com.beust.jcommander.internal.Lists; //导入依赖的package包/类
/**
* 把数组所有元素按照字母顺序排序,并按照“参数=参数值”的模式用“&”字符拼接成字符串
* <p>
* 第一步: 在通知返回参数列表中,除去sign、sign_type两个参数外,凡是通知返回回来的参数皆是待验签的参数。
* 第二步:将剩下参数进行url_decode, 然后进行字典排序,组成字符串,得到待签名字符串
*
* @param params 需要排序并参与字符拼接的参数组
* @return 拼接后字符串
* @Link 异步返回结果的验签:https://doc.open.alipay.com/docs/doc.htm?spm=a219a.7629140.0.0.OSyDs4&treeId=194&articleId=103296&docType=1#s1
*/
public static String createStringUrl(Map<String, String> params) {
List<String> keys = Lists.newArrayList(params.keySet());
Collections.sort(keys);
StringBuffer prestr = new StringBuffer();
int keySize = keys.size();
int lastKeyLength = keySize - 1;
for (int i = 0; i < keySize; i++) {
String key = keys.get(i);
/* if (*//*key.equals("sign") ||*//* key.equals("sign_type")) {//除去sign、sign_type两个参数
continue;
}*/
String value = params.get(key);
if (i == lastKeyLength) {//拼接时,不包括最后一个&字符
prestr.append(key).append("=").append(value);
} else {
prestr.append(key).append("=").append(value).append("&");
}
}
return prestr.toString();
}
示例6: testLeftPush
import com.beust.jcommander.internal.Lists; //导入依赖的package包/类
@Test
public void testLeftPush() throws IOException {
OperatorNode<SequenceOperator> query = OperatorNode.create(SequenceOperator.FILTER,
OperatorNode.create(SequenceOperator.JOIN,
OperatorNode.create(SequenceOperator.SCAN, ImmutableList.of("left"), Lists.newArrayList()).putAnnotation("alias", "left"),
OperatorNode.create(SequenceOperator.SCAN, ImmutableList.of("right"), Lists.newArrayList()).putAnnotation("alias", "right"),
OperatorNode.create(ExpressionOperator.EQ,
OperatorNode.create(ExpressionOperator.PROPREF, OperatorNode.create(ExpressionOperator.READ_RECORD, "left"), "id"),
OperatorNode.create(ExpressionOperator.PROPREF, OperatorNode.create(ExpressionOperator.READ_RECORD, "right"), "id"))
),
OperatorNode.create(ExpressionOperator.EQ,
OperatorNode.create(ExpressionOperator.PROPREF, OperatorNode.create(ExpressionOperator.READ_RECORD, "left"), "id"),
OperatorNode.create(ExpressionOperator.LITERAL, "1"))
);
OperatorNode<SequenceOperator> transformed = new JoinFilterPushDown().visitSequenceOperator(query);
Assert.assertEquals(transformed.getOperator(), SequenceOperator.JOIN);
Assert.assertEquals(((OperatorNode) transformed.getArgument(0)).getOperator(), SequenceOperator.FILTER);
Assert.assertEquals(((OperatorNode) transformed.getArgument(1)).getOperator(), SequenceOperator.SCAN);
// TODO: validate the rest of the tree
}
示例7: testRightPush
import com.beust.jcommander.internal.Lists; //导入依赖的package包/类
@Test
public void testRightPush() throws IOException {
OperatorNode<SequenceOperator> query = OperatorNode.create(SequenceOperator.FILTER,
OperatorNode.create(SequenceOperator.JOIN,
OperatorNode.create(SequenceOperator.SCAN, ImmutableList.of("left"), Lists.newArrayList()).putAnnotation("alias", "left"),
OperatorNode.create(SequenceOperator.SCAN, ImmutableList.of("right"), Lists.newArrayList()).putAnnotation("alias", "right"),
OperatorNode.create(ExpressionOperator.EQ,
OperatorNode.create(ExpressionOperator.PROPREF, OperatorNode.create(ExpressionOperator.READ_RECORD, "left"), "id"),
OperatorNode.create(ExpressionOperator.PROPREF, OperatorNode.create(ExpressionOperator.READ_RECORD, "right"), "id"))
),
OperatorNode.create(ExpressionOperator.EQ,
OperatorNode.create(ExpressionOperator.PROPREF, OperatorNode.create(ExpressionOperator.READ_RECORD, "right"), "id"),
OperatorNode.create(ExpressionOperator.LITERAL, "1"))
);
OperatorNode<SequenceOperator> transformed = new JoinFilterPushDown().visitSequenceOperator(query);
Assert.assertEquals(transformed.getOperator(), SequenceOperator.JOIN);
Assert.assertEquals(((OperatorNode) transformed.getArgument(0)).getOperator(), SequenceOperator.SCAN);
Assert.assertEquals(((OperatorNode) transformed.getArgument(1)).getOperator(), SequenceOperator.FILTER);
// TODO: validate the rest of the tree
}
示例8: getPublicDnsForAutoScalingGroup
import com.beust.jcommander.internal.Lists; //导入依赖的package包/类
/**
* For a given AutoScaling group logical id, get the public dns names associated with each instance.
*
* @param logicalId AutoScaling group logical id
* @return List of public dns names
*/
public List<String> getPublicDnsForAutoScalingGroup(final String logicalId) {
final List<String> instanceIds = Lists.newLinkedList();
final Optional<AutoScalingGroup> autoScalingGroup = describeAutoScalingGroup(logicalId);
final List<String> publicDnsNames = Lists.newLinkedList();
if (autoScalingGroup.isPresent()) {
autoScalingGroup.get()
.getInstances().stream().forEach(instance -> instanceIds.add(instance.getInstanceId()));
final DescribeInstancesRequest describeInstancesRequest = new DescribeInstancesRequest()
.withInstanceIds(instanceIds);
final DescribeInstancesResult describeInstancesResult =
ec2Client.describeInstances(describeInstancesRequest);
describeInstancesResult.getReservations().forEach(reservation ->
reservation.getInstances().stream().forEach(instance ->
publicDnsNames.add(instance.getPublicDnsName()))
);
}
return publicDnsNames;
}
示例9: createSimpleFeatureType
import com.beust.jcommander.internal.Lists; //导入依赖的package包/类
static SimpleFeatureType createSimpleFeatureType(String simpleFeatureTypeName)
throws SchemaException {
// list the attributes that constitute the feature type
List<String> attributes = Lists.newArrayList(
"Who:String:index=full",
"What:java.lang.Long", // some types require full qualification (see DataUtilities docs)
"When:Date", // a date-time field is optional, but can be indexed
"*Where:Point:srid=4326", // the "*" denotes the default geometry (used for indexing)
"Why:String", // you may have as many other attributes as you like...
"Visibility:String"
);
// create the bare simple-feature type
String simpleFeatureTypeSchema = Joiner.on(",").join(attributes);
SimpleFeatureType simpleFeatureType =
SimpleFeatureTypes.createType(simpleFeatureTypeName, simpleFeatureTypeSchema);
// use the user-data (hints) to specify which date-time field is meant to be indexed;
// if you skip this step, your data will still be stored, it simply won't be indexed
simpleFeatureType.getUserData().put(SimpleFeatureTypes.DEFAULT_DATE_KEY, "When");
return simpleFeatureType;
}
示例10: createSimpleFeatureType
import com.beust.jcommander.internal.Lists; //导入依赖的package包/类
static SimpleFeatureType createSimpleFeatureType(String simpleFeatureTypeName)
throws SchemaException {
// list the attributes that constitute the feature type
List<String> attributes = Lists.newArrayList(
"Who:String:index=full",
"What:java.lang.Long", // some types require full qualification (see DataUtilities docs)
"When:Date", // a date-time field is optional, but can be indexed
"*Where:Point:srid=4326", // the "*" denotes the default geometry (used for indexing)
"Why:String" // you may have as many other attributes as you like...
);
// create the bare simple-feature type
String simpleFeatureTypeSchema = Joiner.on(",").join(attributes);
SimpleFeatureType simpleFeatureType =
SimpleFeatureTypes.createType(simpleFeatureTypeName, simpleFeatureTypeSchema);
// use the user-data (hints) to specify which date-time field is meant to be indexed;
// if you skip this step, your data will still be stored, it simply won't be indexed
simpleFeatureType.getUserData().put(SimpleFeatureTypes.DEFAULT_DATE_KEY, "When");
return simpleFeatureType;
}
示例11: createSimpleFeatureType
import com.beust.jcommander.internal.Lists; //导入依赖的package包/类
static SimpleFeatureType createSimpleFeatureType(String simpleFeatureTypeName)
throws SchemaException {
// list the attributes that constitute the feature type
List<String> attributes = Lists.newArrayList(
"Who:String",
"What:java.lang.Long", // some types require full qualification (see DataUtilities docs)
"When:Date", // a date-time field is optional, but can be indexed
"*Where:Point:srid=4326", // the "*" denotes the default geometry (used for indexing)
"Why:String" // you may have as many other attributes as you like...
);
// create the bare simple-feature type
String simpleFeatureTypeSchema = Joiner.on(",").join(attributes);
SimpleFeatureType simpleFeatureType =
DataUtilities.createType(simpleFeatureTypeName, simpleFeatureTypeSchema);
return simpleFeatureType;
}
示例12: getGraylogAddresses
import com.beust.jcommander.internal.Lists; //导入依赖的package包/类
@Nullable
public List<GraylogAddress> getGraylogAddresses() {
if(graylogAddresses == null) {
return null;
}
String[] addresses;
if (graylogAddresses.contains(",")) {
addresses = graylogAddresses.split(",");
} else {
addresses = new String[]{graylogAddresses};
}
List<GraylogAddress> result = Lists.newArrayList();
for (String address : addresses) {
String[] parts = address.split(":");
result.add(new GraylogAddress(parts[0], Integer.parseInt(parts[1])));
}
return result;
}
示例13: readFile
import com.beust.jcommander.internal.Lists; //导入依赖的package包/类
/**
* Reads the file specified by filename and returns the file content as a string.
* End of lines are replaced by a space.
*
* @param fileName the command line filename
* @return the file content as a string.
*/
private static List<String> readFile(String fileName) {
List<String> result = Lists.newArrayList();
try {
BufferedReader bufRead = new BufferedReader(new FileReader(fileName));
String line;
// Read through file one line at time. Print line # and line
while ((line = bufRead.readLine()) != null) {
// Allow empty lines in these at files
if (line.length() > 0) result.add(line);
}
bufRead.close();
}
catch (IOException e) {
throw new ParameterException("Could not read file " + fileName + ": " + e);
}
return result;
}
示例14: processVariableArity
import com.beust.jcommander.internal.Lists; //导入依赖的package包/类
/**
* @return the number of options that were processed.
*/
private int processVariableArity(String[] args, int index, ParameterDescription pd) {
Object arg = pd.getObject();
IVariableArity va;
if (! (arg instanceof IVariableArity)) {
va = DEFAULT_VARIABLE_ARITY;
} else {
va = (IVariableArity) arg;
}
List<String> currentArgs = Lists.newArrayList();
for (int j = index + 1; j < args.length; j++) {
currentArgs.add(args[j]);
}
int arity = va.processVariableArity(pd.getParameter().names()[0],
currentArgs.toArray(new String[0]));
int result = processFixedArity(args, index, pd, List.class, arity);
return result;
}
示例15: getMainParameter
import com.beust.jcommander.internal.Lists; //导入依赖的package包/类
/**
* @return the field that's meant to receive all the parameters that are not options.
*
* @param arg the arg that we're about to add (only passed here to output a meaningful
* error message).
*/
private List<?> getMainParameter(String arg) {
if (m_mainParameter == null) {
throw new ParameterException(
"Was passed main parameter '" + arg + "' but no main parameter was defined");
}
List<?> result = (List<?>) m_mainParameter.get(m_mainParameterObject);
if (result == null) {
result = Lists.newArrayList();
if (! List.class.isAssignableFrom(m_mainParameter.getType())) {
throw new ParameterException("Main parameter field " + m_mainParameter
+ " needs to be of type List, not " + m_mainParameter.getType());
}
m_mainParameter.set(m_mainParameterObject, result);
}
if (m_firstTimeMainParameter) {
result.clear();
m_firstTimeMainParameter = false;
}
return result;
}