当前位置: 首页>>代码示例>>Java>>正文


Java Lists.newArrayList方法代码示例

本文整理汇总了Java中com.beust.jcommander.internal.Lists.newArrayList方法的典型用法代码示例。如果您正苦于以下问题:Java Lists.newArrayList方法的具体用法?Java Lists.newArrayList怎么用?Java Lists.newArrayList使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.beust.jcommander.internal.Lists的用法示例。


在下文中一共展示了Lists.newArrayList方法的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: 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

示例4: 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

示例5: 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

示例6: 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

示例7: 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

示例8: 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

示例9: 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

示例10: 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

示例11: findExpiredConsumers

import com.beust.jcommander.internal.Lists; //导入方法依赖的package包/类
/**
 * @return list of expired consumers to be deleted from Bitbucket
 */
private List<BitbucketConsumer> findExpiredConsumers(final String repoOwner, final String repoPassword)
{
    ConsumerRemoteRestpoint consumerRemoteRestpoint = createConsumerRemoteRestpoint(repoOwner, repoPassword);
    List<BitbucketConsumer> expiredConsumers = Lists.newArrayList();

    List<BitbucketConsumer> consumers = consumerRemoteRestpoint.getConsumers(repoOwner);
    for (BitbucketConsumer consumer : consumers)
    {
        if (super.isConsumerExpired(consumer.getName()))
        {
            expiredConsumers.add(consumer);
        }
    }
    return expiredConsumers;
}
 
开发者ID:edgehosting,项目名称:jira-dvcs-connector,代码行数:19,代码来源:DeleteBitbucketOrphanAppsTest.java

示例12: filterResource

import com.beust.jcommander.internal.Lists; //导入方法依赖的package包/类
/**
 * Filter resources, get all valid resources from all resources
 */
public static <T extends MPersistableEntity> List<T> filterResource(final MResource.TYPE type, List<T> resources) throws SqoopException {
  Collection<T> collection = Collections2.filter(resources, new Predicate<T>() {
    @Override
    public boolean apply(T input) {
      try {
        String name = String.valueOf(input.getPersistenceId());
        checkPrivilege(getPrivilege(type, name, MPrivilege.ACTION.READ));
        // add valid resource
        return true;
      } catch (Exception e) {
        //do not add into result if invalid resource
        return false;
      }
    }
  });
  return Lists.newArrayList(collection);
}
 
开发者ID:vybs,项目名称:sqoop-on-spark,代码行数:21,代码来源:AuthorizationEngine.java

示例13: test

import com.beust.jcommander.internal.Lists; //导入方法依赖的package包/类
@Test
public void test() throws IOException {
  FileSystem fs = mock(FileSystem.class);

  String datasetPathStr = "/path/to/dataset";
  String dataset1 = "datasetVersion1";
  String dataset2 = "datasetVersion2";
  Path datasetPath = new Path(datasetPathStr);
  Path globbedPath = new Path(datasetPathStr + "/*");
  Path datasetVersion1 = new Path(datasetPathStr + "/" + dataset1);
  Path datasetVersion2 = new Path(datasetPathStr + "/" + dataset2);

  when(fs.globStatus(globbedPath)).
      thenReturn(new FileStatus[]{new FileStatus(0, true, 0, 0, 0, datasetVersion1),
          new FileStatus(0, true, 0, 0, 0, datasetVersion2)});

  DatasetVersionFinder<StringDatasetVersion> versionFinder = new MockDatasetVersionFinder(fs, new Properties());

  List<StringDatasetVersion> datasetVersions =
      Lists.newArrayList(versionFinder.findDatasetVersions(new MockDataset(datasetPath)));
  Assert.assertEquals(datasetVersions.size(), 2);
  Assert.assertEquals(datasetVersions.get(0).getVersion(), dataset1);
  Assert.assertEquals(datasetVersions.get(0).getPathsToDelete().iterator().next(), datasetVersion1);
  Assert.assertEquals(datasetVersions.get(1).getVersion(), dataset2);
  Assert.assertEquals(datasetVersions.get(1).getPathsToDelete().iterator().next(), datasetVersion2);
}
 
开发者ID:Hanmourang,项目名称:Gobblin,代码行数:27,代码来源:DatasetVersionFinderTest.java

示例14: getFilesToParse

import com.beust.jcommander.internal.Lists; //导入方法依赖的package包/类
/**
 * Based on the previously parsed files and the provided log files, this method determines which new files are to be
 * parsed. Generally, "Launch.log" will always be scanned.
 * 
 * @param scannedFiles the {@link ScannedFiles} instance.
 * @param logFiles the Rocket League log files available.
 * @return a list of files to parse.
 */
protected List<File> getFilesToParse(final ScannedFiles scannedFiles, final File[] logFiles)
{
  retainLogFiles(scannedFiles, logFiles);
  final List<File> filesToParse = Lists.newArrayList();
  for (File file : logFiles)
  {
    if (file.getName().equals(DEFAULT_LOGFILE))
    {
      filesToParse.add(file);
    }
    else if (!scannedFiles.getLogFiles().contains(file.getName()))
    {
      filesToParse.add(file);
      scannedFiles.getLogFiles().add(file.getName());
    }
  }
  return filesToParse;
}
 
开发者ID:trew,项目名称:RankTracker,代码行数:27,代码来源:ScanTask.java

示例15: 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:jgaltidor,项目名称:VarJ,代码行数:23,代码来源:JCommander.java


注:本文中的com.beust.jcommander.internal.Lists.newArrayList方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。