Java Code Examples for java.util.List.toString()

The following are Jave code examples for showing how to use toString() of the java.util.List class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: my-diploma-work   File: KnowledgeBaseFrame.java   Source Code and License Vote up 7 votes
private void setDataToTable(List<Eat> eats) {
    DefaultTableModel df = (DefaultTableModel) jTable1.getModel();
    df.getDataVector().removeAllElements();
    df.fireTableDataChanged();
    for (Eat eat : eats) {
        List<String> foods = new ArrayList<>();
        for (Food food : eat.getFoods()) {
            foods.add(food.getFood());
        }
        Object[] row = new Object[]{
            eat.getId(),
            eat.getName(),
            foods.toString()
        };
        df.addRow(row);
    }
    df.fireTableDataChanged();
}
 
Example 2
Project: openjdk-jdk10   File: BuilderForwarding.java   Source Code and License Vote up 6 votes
public void insertintObject() {
    StringBuilder sb = new StringBuilder("012345");
    List<String> ls = new ArrayList<String>();
    ls.add("A"); ls.add("B");
    String lsString = ls.toString();
    assertEquals( sb.insert(2, ls).toString(), "01"+lsString+"2345");

    try {
        sb.insert(sb.length()+1, ls);
        throw new RuntimeException("Test failed: should have thrown StringIndexOutOfBoundsException");
    } catch (StringIndexOutOfBoundsException soob) {
        // expected: passed
    } catch (Throwable t) {
        throw new RuntimeException("Test failed: should have thrown StringIndexOutOfBoundsException, but instead threw:"
                + t);
    }
}
 
Example 3
Project: happylifeplat-tcc   File: TccTransactionManager.java   Source Code and License Vote up 6 votes
private void executeHandler(boolean success, final TccTransaction currentTransaction,
                            List<Participant> failList) {
    if (success) {
        TransactionContextLocal.getInstance().remove();
        coordinatorCommand.execute(new CoordinatorAction(CoordinatorActionEnum.DELETE, currentTransaction));
    } else {
        //获取还没执行的,或者执行失败的
        currentTransaction.setParticipants(failList);
        coordinatorService.updateParticipant(currentTransaction);
        throw new TccRuntimeException(failList.toString());
    }
}
 
Example 4
Project: jdk8u-jdk   File: BuilderForwarding.java   Source Code and License Vote up 6 votes
public void insertintObject() {
    StringBuilder sb = new StringBuilder("012345");
    List<String> ls = new ArrayList<String>();
    ls.add("A"); ls.add("B");
    String lsString = ls.toString();
    assertEquals( sb.insert(2, ls).toString(), "01"+lsString+"2345");

    try {
        sb.insert(sb.length()+1, ls);
        throw new RuntimeException("Test failed: should have thrown StringIndexOutOfBoundsException");
    } catch (StringIndexOutOfBoundsException soob) {
        // expected: passed
    } catch (Throwable t) {
        throw new RuntimeException("Test failed: should have thrown StringIndexOutOfBoundsException, but instead threw:"
                + t);
    }
}
 
Example 5
Project: tscfg-docgen   File: Configuration.java   Source Code and License Vote up 5 votes
public Builder addGroupDefinition(GroupDefinition groupDefinition) {
  for (GroupDefinition existingDef : groupDefinitions) {
    List<String> existingPrefixes = new ArrayList<>(existingDef.getPrefixes());
    existingPrefixes.retainAll(groupDefinition.getPrefixes());
    if (!existingPrefixes.isEmpty()) {
      throw new IllegalArgumentException(
          "Duplicate group prefixes: " + existingPrefixes.toString());
    }
  }
  groupDefinitions.add(groupDefinition);
  return this;
}
 
Example 6
Project: JavaRestCalculator   File: FunctionsController.java   Source Code and License Vote up 5 votes
@RequestMapping(method = RequestMethod.GET, consumes = "text/plain", produces = "text/plain")
public String getListOfAllFunctions(Authentication account) throws ParsingException {
    LOG.debug("Printing the list of all functions:\n");
    List funcList = dbms.getListOfAllFunctions(account.getName());
    String response;
    if (funcList.isEmpty()) {
        LOG.trace("User " + account.getName() + " has no specified functions");
        response = "You have no specified functions for now";
    } else {
        LOG.trace("List of all functions: " + funcList.toString());
        response = funcList.toString();
    }
    return response;
}
 
Example 7
Project: GitHub   File: URLConnectionTest.java   Source Code and License Vote up 5 votes
private String certificatesToString(X509Certificate[] certificates) {
  List<String> result = new ArrayList<>();
  for (X509Certificate certificate : certificates) {
    result.add(certificate.getSubjectDN() + " " + certificate.getSerialNumber());
  }
  return result.toString();
}
 
Example 8
Project: GitHub   File: JsonParserReader.java   Source Code and License Vote up 5 votes
private String getLocationString() {
  JsonLocation l = parser.getCurrentLocation();
  List<String> parts = new ArrayList<>(4);
  parts.add("line: " + l.getLineNr());
  parts.add("column: " + l.getColumnNr());
  if (l.getByteOffset() >= 0) {
    parts.add("byte offset: " + l.getByteOffset());
  }
  return parts.toString();
}
 
Example 9
Project: Lispreter   File: SExpression.java   Source Code and License Vote up 5 votes
/**
 * Appropriately updates tokens, determines address and data tokens, and
 * validifies the representation of a given S-Expression, in the form of a
 * string list.
 * 
 * @param tokens
 */
private void makeCons(List<String> tokens) {
    if (tokens.size() > 0 && Pat.PAREN_OPEN.matches(tokens.get(0))) {
        int index = 1;
        int dataBegin = 3;
        if (Pat.PAREN_OPEN.matches(tokens.get(index))) {
            int numClausesOpen = 1;
            while (numClausesOpen > 0 && index < tokens.size()) {
                index++;
                if (Pat.PAREN_OPEN.matches(tokens.get(index))) {
                    numClausesOpen++;
                } else if (Pat.PAREN_CLOSE.matches(tokens.get(index))) {
                    numClausesOpen--;
                }
            }
            dataBegin = index + 1;
        }
        index = dataBegin > 3 ? ListUtils.subList(tokens, dataBegin, true)
                .indexOf(".") + dataBegin : 2;

        addrTokens = ListUtils.subList(tokens, 1, index, true);
        dataTokens = ListUtils.subList(tokens, index + 1,
                tokens.size() - 1, true);

        data = NodeFactory.makeNode(dataTokens);
        addr = NodeFactory.makeNode(addrTokens);
        buildTokens();
        return;
    }
    throw new NodeInitException("Invalid S-Expression provided : "
            + tokens.toString());
}
 
Example 10
Project: janusgraph-utils   File: CSVGenerator.java   Source Code and License Vote up 5 votes
/**
 * Validates a csv config file
 * @param config CSVConfig object
 */
public static void isValidConfig(CSVConfig config){
    //TODO 1. one2one , many2one cannot have supernode
    //     2. selfRef is only for same left and right vertex types
    //     3. one2many , one2many cannot have more edges than the right vertex
    List<String> typeArray = new ArrayList<String>();
    config.VertexTypes.forEach(vertextype -> typeArray.add(vertextype.name));
    for (EdgeTypeBean edgeType: config.EdgeTypes){
        for (RelationBean relation: edgeType.relations) {
        //validate left and right are in the vertex types
            if(!typeArray.contains(relation.left)){
                throw new RuntimeException("relationships: "
                        + relation.left + " is not of vertex types: " + typeArray.toString());}
            if(!typeArray.contains(relation.right))
                throw new RuntimeException("relationships: "
                        + relation.right + " is not of vertex types: " + typeArray.toString());
            //validate supernode vertices don't exceed the number of vertices
            Iterator<VertexTypeBean> vTypes = config.VertexTypes.iterator();
            while (vTypes.hasNext()){
                VertexTypeBean type = vTypes.next();
                if (relation.left.equals(type.name) &&
                    relation.supernode != null &&
                    relation.supernode.get("vertices") > type.row){
                    ObjectMapper mapper = new ObjectMapper();
                    try {
                        mapper.writeValueAsString(relation);
                        throw new RuntimeException(
                            mapper.writeValueAsString(relation) +
                            "supernode.vertices is greater than " +
                            type.name + "'s row"
                        );
                    } catch (JsonProcessingException e) {
                        e.printStackTrace();
                    }
                }
            }
        }
    }
}
 
Example 11
Project: openjdk-jdk10   File: DeadCode.java   Source Code and License Vote up 5 votes
void test() {
    List<? extends @A Object> o = null;
    o.toString();

    @A String m;
    if (false) {
        @A String a;
        @A String b = "m";
        b.toString();
        List<? extends @A Object> c = null;
        c.toString();
    }
}
 
Example 12
Project: MailTrigger   File: PlaceholderProcessor.java   Source Code and License Vote up 5 votes
private void checkForRemainingPlaceholders(String output) {
    List<String> remainingPlaceHolders = new ArrayList<>();
    Matcher matcher = placeholderPattern.matcher(output);
    while (matcher.find()) {
        for (int i = 0; i <= matcher.groupCount(); i++) {
            if (i > 0) {
                remainingPlaceHolders.add(matcher.group(i));
            }
        }
    }

    if (!remainingPlaceHolders.isEmpty()) {
        throw new ReplacementsMissingException(remainingPlaceHolders.toString());
    }
}
 
Example 13
Project: personium-core   File: UserDataDocHandler.java   Source Code and License Vote up 5 votes
@Override
public String getManyToOnelinkIdString() {
    List<String> newList = new ArrayList<String>();
    List<String> linkList = toArrayManyToOnelink();
    for (String element : linkList) {
        newList.add("\"" + element + "\"");
    }
    return newList.toString();
}
 
Example 14
Project: KeYExperienceReport   File: ExperimentToExcel.java   Source Code and License Vote up 5 votes
@Override
public int compare(List<String> o1, List<String> o2) {
	if(o1.size() < 4 || o2.size() < 4){
		throw new IllegalArgumentException(o1.toString());
	}
	
	int c = 0;
	for(int num : new int[]{1,2,0,4,3}){
		c = o1.get(num).compareTo(o2.get(num));
		if (c != 0) break;
	}
	return c;
}
 
Example 15
Project: guava-mock   File: FeatureSpecificTestSuiteBuilder.java   Source Code and License Vote up 5 votes
protected static String formatFeatureSet(Set<? extends Feature<?>> features) {
  List<String> temp = new ArrayList<String>();
  for (Feature<?> feature : features) {
    Object featureAsObject = feature; // to work around bogus JDK warning
    if (featureAsObject instanceof Enum) {
      Enum<?> f = (Enum<?>) featureAsObject;
      temp.add(f.getDeclaringClass().getSimpleName() + "." + feature);
    } else {
      temp.add(feature.toString());
    }
  }
  return temp.toString();
}
 
Example 16
Project: clingo4j   File: Model.java   Source Code and License Vote up 5 votes
@Override
public String toString() {
    try {
        List<Symbol> tmp = Model.this.getSymbols();
        return tmp.toString();
    } catch (ClingoException ex) {
        throw new RuntimeException(ex.getMessage(), ex);
    }
}
 
Example 17
Project: BizareChat   File: MessageModel.java   Source Code and License Vote up 4 votes
@Override
public String convertToDatabaseValue(List<Integer> entityProperty) {
    return entityProperty.toString();
}
 
Example 18
Project: class-code   File: Tester.java   Source Code and License Vote up 4 votes
public static boolean testPart2(List<Integer> ell) {

    Stopwatch s = new Stopwatch();

    ell.add(0, 1);
    if (ell.get(0) != 1) {
      return false;
    }


    ell.remove(0);

    ell.add(0,0);
    ell.add(0,99);
    if (ell.get(0) != 99) {
      return false;
    }

    ell.remove(0);
    ell.remove(0);

    //add to end
    s.start();
    for (int i = 0; i < testCount; i++) {
    	ell.add(i, i);
      if (ell.get(i) != i) {
        return false;
      }
    }
    s.stop();
    if (s.elapsedSeconds() > t) {
    	return false;
    }

    System.out.println(ell);

    s.start();
    for (int i = 0; i < testCount; i++) {
      ell.remove(0);
    }
    s.stop();
    if (s.elapsedSeconds() > t) {
    	return false;
    }
    System.out.println(ell);

    for (int i = 0; i < testCount; i++) {
      ell.add(0, i);
    }

    for (int i = testCount-1; i >= 0; i--) {
      ell.remove(i);
    }


    //System.out.println(ell);

    ell.toString();

		return true;
	}
 
Example 19
Project: jdk8u-jdk   File: SpinedBuffer.java   Source Code and License Vote up 4 votes
@Override
public String toString() {
    List<E> list = new ArrayList<>();
    forEach(list::add);
    return "SpinedBuffer:" + list.toString();
}
 
Example 20
Project: dremio-oss   File: QueryIdHelper.java   Source Code and License Vote up 4 votes
public static String getQueryIdentifiers(final QueryId queryId, final int majorFragmentId, final List<Integer> minorFragmentIds) {
  final String fragmentIds = minorFragmentIds.size() == 1 ? minorFragmentIds.get(0).toString() : minorFragmentIds.toString();
  return getQueryId(queryId) + ":" + majorFragmentId + ":" + fragmentIds;
}