當前位置: 首頁>>代碼示例>>Java>>正文


Java Lists類代碼示例

本文整理匯總了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;
}
 
開發者ID:georghinkel,項目名稱:ttc2017smartGrids,代碼行數:26,代碼來源:JCommander.java

示例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;
}
 
開發者ID:georghinkel,項目名稱:ttc2017smartGrids,代碼行數:28,代碼來源:JCommander.java

示例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));
}
 
開發者ID:inferjay,項目名稱:r8,代碼行數:23,代碼來源:D8IncrementalRunExamplesAndroidOTest.java

示例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;
}
 
開發者ID:fanqinghui,項目名稱:wish-pay,代碼行數:32,代碼來源:WxUtils.java

示例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();
}
 
開發者ID:fanqinghui,項目名稱:wish-pay,代碼行數:36,代碼來源:AliPayUtil.java

示例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
}
 
開發者ID:yahoo,項目名稱:yql-plus,代碼行數:21,代碼來源:JoinFilterPushDownTest.java

示例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
}
 
開發者ID:yahoo,項目名稱:yql-plus,代碼行數:21,代碼來源:JoinFilterPushDownTest.java

示例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;
}
 
開發者ID:Nike-Inc,項目名稱:cerberus-lifecycle-cli,代碼行數:29,代碼來源:AutoScalingService.java

示例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;
}
 
開發者ID:geomesa,項目名稱:geomesa-tutorials,代碼行數:25,代碼來源:FeatureLevelVisibility.java

示例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;
}
 
開發者ID:geomesa,項目名稱:geomesa-tutorials,代碼行數:24,代碼來源:AccumuloQuickStart.java

示例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;
}
 
開發者ID:geomesa,項目名稱:geomesa-tutorials,代碼行數:20,代碼來源:HBaseQuickStart.java

示例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;
}
 
開發者ID:lennartkoopmann,項目名稱:nzyme,代碼行數:23,代碼來源:Configuration.java

示例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;
}
 
開發者ID:jeffoffutt,項目名稱:muJava,代碼行數:30,代碼來源:JCommander.java

示例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;
}
 
開發者ID:jeffoffutt,項目名稱:muJava,代碼行數:23,代碼來源:JCommander.java

示例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;
}
 
開發者ID:jeffoffutt,項目名稱:muJava,代碼行數:28,代碼來源:JCommander.java


注:本文中的com.beust.jcommander.internal.Lists類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。