本文整理了Java中javaslang.collection.List.get()
方法的一些代码示例,展示了List.get()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。List.get()
方法的具体详情如下:
包路径:javaslang.collection.List
类名称:List
方法名:get
暂无
代码示例来源:origin: com.io7m.smfj/io7m-smfj-parser-api
@Override
public void onMetaData(
final long vendor,
final long schema,
final byte[] data)
{
for (int index = 0; index < this.want.length; ++index) {
if (this.want[index]) {
this.delegates.get(index).onMetaData(vendor, schema, data);
}
}
}
}
代码示例来源:origin: com.io7m.smfj/io7m-smfj-parser-api
@Override
public boolean onMeta(
final long vendor,
final long schema,
final long length)
{
boolean any = false;
for (int index = 0; index < this.want.length; ++index) {
final boolean want_now =
this.delegates.get(index).onMeta(vendor, schema, length);
this.want[index] = want_now;
any = any || want_now;
}
return any;
}
代码示例来源:origin: com.io7m.smfj/io7m-smfj-format-text
private void parseMeta(
final List<String> line)
throws Exception
{
if (line.length() == 4) {
final long vendor_id =
(long) Integer.parseUnsignedInt(line.get(1), 16);
final long schema_id =
(long) Integer.parseUnsignedInt(line.get(2), 16);
final long lines =
Long.parseUnsignedLong(line.get(3));
this.parseMetaDataValues(vendor_id, schema_id, lines);
} else {
super.failExpectedGot(
"Incorrect number of arguments",
"meta <vendor-id> <schema-id> <integer-unsigned>",
line.toJavaStream().collect(Collectors.joining(" ")));
}
}
代码示例来源:origin: com.io7m.smfj/com.io7m.smfj.validation.main
private Validation<List<SMFParseError>, SMFSchemaRequireTriangles>
parseStatementRequireTriangles(
final List<String> line)
{
if (line.size() == 2) {
final String text = line.get(1);
switch (text) {
case "true":
return valid(SMF_TRIANGLES_REQUIRED);
case "false":
return valid(SMF_TRIANGLES_NOT_REQUIRED);
default:
break;
}
}
final StringBuilder sb = new StringBuilder(128);
sb.append("Could not parse triangle requirement.");
sb.append(System.lineSeparator());
sb.append(" Expected: require-triangles (true | false)");
sb.append(System.lineSeparator());
sb.append(" Received: ");
sb.append(line.toJavaStream().collect(Collectors.joining(" ")));
sb.append(System.lineSeparator());
return invalid(List.of(SMFParseError.of(
this.reader.position(),
sb.toString(),
Optional.empty())));
}
代码示例来源:origin: com.io7m.smfj/com.io7m.smfj.validation.main
private Validation<List<SMFParseError>, SMFSchemaRequireVertices>
parseStatementRequireVertices(
final List<String> line)
{
if (line.size() == 2) {
final String text = line.get(1);
switch (text) {
case "true":
return valid(SMF_VERTICES_REQUIRED);
case "false":
return valid(SMF_VERTICES_NOT_REQUIRED);
default:
break;
}
}
final StringBuilder sb = new StringBuilder(128);
sb.append("Could not parse vertices requirement.");
sb.append(System.lineSeparator());
sb.append(" Expected: require-vertices (true | false)");
sb.append(System.lineSeparator());
sb.append(" Received: ");
sb.append(line.toJavaStream().collect(Collectors.joining(" ")));
sb.append(System.lineSeparator());
return invalid(List.of(SMFParseError.of(
this.reader.position(),
sb.toString(),
Optional.empty())));
}
代码示例来源:origin: com.io7m.smfj/io7m-smfj-format-text
private void parseHeaderCommandSchema(
final List<String> line)
{
if (line.size() == 5) {
try {
final int vendor =
Integer.parseUnsignedInt(line.get(1), 16);
final int schema =
Integer.parseUnsignedInt(line.get(2), 16);
final int schema_version_major =
Integer.parseUnsignedInt(line.get(3));
final int schema_version_minor =
Integer.parseUnsignedInt(line.get(4));
this.schema_id = SMFSchemaIdentifier.of(
vendor, schema, schema_version_major, schema_version_minor);
} catch (final NumberFormatException e) {
super.failExpectedGot(
"Could not parse number: " + e.getMessage(),
"schema <vendor-id> <schema-id> <schema-version-major> <schema-version-minor>",
line.toJavaStream().collect(Collectors.joining(" ")));
}
} else {
super.failExpectedGot(
"Incorrect number of arguments",
"schema <vendor-id> <schema-id> <schema-version-major> <schema-version-minor>",
line.toJavaStream().collect(Collectors.joining(" ")));
}
}
代码示例来源:origin: com.io7m.smfj/com.io7m.smfj.validation.main
private Validation<List<SMFParseError>, SMFSchemaIdentifier>
parseStatementIdentifier(
final List<String> text)
{
if (text.length() == 4) {
try {
final SMFSchemaName schema = SMFSchemaName.of(text.get(1));
final int major = Integer.parseUnsignedInt(text.get(2));
final int minor = Integer.parseUnsignedInt(text.get(3));
return valid(SMFSchemaIdentifier.of(schema, major, minor));
} catch (final NumberFormatException e) {
return invalid(List.of(SMFParseError.of(
this.reader.position(), e.getMessage(), Optional.of(e))));
}
}
final StringBuilder sb = new StringBuilder(128);
sb.append("Incorrect number of arguments.");
sb.append(System.lineSeparator());
sb.append(
" Expected: schema <schema> <version-major> <version-minor>");
sb.append(System.lineSeparator());
sb.append(" Received: ");
sb.append(text.toJavaStream().collect(Collectors.joining(" ")));
sb.append(System.lineSeparator());
return invalid(List.of(SMFParseError.of(
this.reader.position(),
sb.toString(),
Optional.empty())));
}
代码示例来源:origin: com.io7m.smfj/io7m-smfj-core
/**
* @return The attributes by name
*/
@Value.Derived
default SortedMap<SMFAttributeName, SMFAttribute> attributesByName()
{
SortedMap<SMFAttributeName, SMFAttribute> m = TreeMap.empty();
final List<SMFAttribute> ordered = this.attributesInOrder();
for (int index = 0; index < ordered.size(); ++index) {
final SMFAttribute attr = ordered.get(index);
if (m.containsKey(attr.name())) {
final StringBuilder sb = new StringBuilder(128);
sb.append("Duplicate attribute name.");
sb.append(System.lineSeparator());
sb.append(" Attribute: ");
sb.append(attr.name().value());
sb.append(System.lineSeparator());
throw new IllegalArgumentException(sb.toString());
}
m = m.put(attr.name(), attr);
}
return m;
}
代码示例来源:origin: com.io7m.smfj/com.io7m.smfj.core
/**
* @return The attributes by name
*/
@Value.Derived
default SortedMap<SMFAttributeName, SMFAttribute> attributesByName()
{
SortedMap<SMFAttributeName, SMFAttribute> m = TreeMap.empty();
final List<SMFAttribute> ordered = this.attributesInOrder();
for (int index = 0; index < ordered.size(); ++index) {
final SMFAttribute attr = ordered.get(index);
if (m.containsKey(attr.name())) {
final StringBuilder sb = new StringBuilder(128);
sb.append("Duplicate attribute name.");
sb.append(System.lineSeparator());
sb.append(" Attribute: ");
sb.append(attr.name().value());
sb.append(System.lineSeparator());
throw new IllegalArgumentException(sb.toString());
}
m = m.put(attr.name(), attr);
}
return m;
}
代码示例来源:origin: com.io7m.smfj/com.io7m.smfj.validation.main
private Validation<List<SMFErrorType>, SMFSchemaVersion> parseVersion(
final LexicalPosition<URI> position,
final List<String> line)
{
if (line.size() == 3) {
final String name = line.get(0);
if (!Objects.equals(name, "smf-schema")) {
return invalid(List.of(
this.unparseableVersionList(line, Optional.empty())));
}
try {
final int major = Integer.parseUnsignedInt(line.get(1));
final int minor = Integer.parseUnsignedInt(line.get(2));
return valid(SMFSchemaVersion.of(major, minor));
} catch (final NumberFormatException e) {
return invalid(List.of(
this.unparseableVersionList(line, Optional.of(e))));
}
}
return invalid(List.of(
this.unparseableVersionList(line, Optional.empty())));
}
代码示例来源:origin: com.io7m.smfj/com.io7m.smfj.processing.main
Optional<Pair<Integer, Integer>> schema_version = Optional.empty();
if (Objects.equals(text.get(0), "-")) {
schema_name = Optional.empty();
} else {
schema_name = Optional.of(SMFSchemaName.of(text.get(0)));
final int major = Integer.parseUnsignedInt(text.get(1));
final int minor = Integer.parseUnsignedInt(text.get(2));
schema_version =
Optional.of(Pair.pair(
代码示例来源:origin: com.io7m.smfj/io7m-smfj-format-text
final CAxis axis_right = CAxis.of(line.get(1));
final CAxis axis_up = CAxis.of(line.get(2));
final CAxis axis_forward = CAxis.of(line.get(3));
final SMFFaceWindingOrder order =
SMFFaceWindingOrder.fromName(line.get(4));
代码示例来源:origin: com.io7m.smfj/com.io7m.smfj.processing.main
/**
* Attempt to parse a command.
*
* @param file The file, if any
* @param line The line
* @param text The text
*
* @return A parsed command or a list of parse errors
*/
public static Validation<List<SMFParseError>, SMFMemoryMeshFilterType> parse(
final Optional<URI> file,
final int line,
final List<String> text)
{
NullCheck.notNull(file, "file");
NullCheck.notNull(text, "text");
if (text.length() == 4) {
try {
final SMFSchemaName name = SMFSchemaName.of(text.get(0));
final int major = Integer.parseUnsignedInt(text.get(1));
final int minor = Integer.parseUnsignedInt(text.get(2));
final Path path = Paths.get(text.get(3));
return valid(create(SMFSchemaIdentifier.of(name, major, minor), path));
} catch (final IllegalArgumentException e) {
return errorExpectedGotValidation(file, line, makeSyntax(), text);
}
}
return errorExpectedGotValidation(file, line, makeSyntax(), text);
}
代码示例来源:origin: com.io7m.smfj/io7m-smfj-format-text
switch (line.get(0)) {
case "smf": {
if (line.length() != 3) {
final int major = Integer.parseUnsignedInt(line.get(1));
final int minor = Integer.parseUnsignedInt(line.get(2));
return valid(SMFFormatVersion.of(major, minor));
} catch (final NumberFormatException e) {
代码示例来源:origin: com.io7m.smfj/com.io7m.smfj.processing.main
/**
* Attempt to parse a command.
*
* @param file The file, if any
* @param line The line
* @param text The text
*
* @return A parsed command or a list of parse errors
*/
public static Validation<List<SMFParseError>, SMFMemoryMeshFilterType> parse(
final Optional<URI> file,
final int line,
final List<String> text)
{
NullCheck.notNull(file, "file");
NullCheck.notNull(text, "text");
if (text.length() == 2) {
try {
final SMFAttributeName name = SMFAttributeName.of(text.get(0));
final int size = Integer.parseUnsignedInt(text.get(1));
return valid(create(name, size));
} catch (final IllegalArgumentException e) {
return errorExpectedGotValidation(file, line, makeSyntax(), text);
}
}
return errorExpectedGotValidation(file, line, makeSyntax(), text);
}
代码示例来源:origin: com.io7m.smfj/com.io7m.smfj.processing.main
/**
* Attempt to parse a command.
*
* @param file The file, if any
* @param line The line
* @param text The text
*
* @return A parsed command or a list of parse errors
*/
public static Validation<List<SMFParseError>, SMFMemoryMeshFilterType> parse(
final Optional<URI> file,
final int line,
final List<String> text)
{
NullCheck.notNull(file, "file");
NullCheck.notNull(text, "text");
if (text.length() == 2) {
try {
final SMFAttributeName source = SMFAttributeName.of(text.get(0));
final SMFAttributeName target = SMFAttributeName.of(text.get(1));
return Validation.valid(
create(source, target));
} catch (final IllegalArgumentException e) {
return errorExpectedGotValidation(file, line, makeSyntax(), text);
}
}
return errorExpectedGotValidation(file, line, makeSyntax(), text);
}
代码示例来源:origin: com.io7m.smfj/com.io7m.smfj.processing.main
final SMFSchemaName schema = SMFSchemaName.of(text.get(0));
final int major = Integer.parseUnsignedInt(text.get(1));
final int minor = Integer.parseUnsignedInt(text.get(2));
return valid(create(
SMFSchemaIdentifier.builder()
代码示例来源:origin: com.io7m.smfj/com.io7m.smfj.processing.main
/**
* Attempt to parse a command.
*
* @param file The file, if any
* @param line The line
* @param text The text
*
* @return A parsed command or a list of parse errors
*/
public static Validation<List<SMFParseError>, SMFMemoryMeshFilterType> parse(
final Optional<URI> file,
final int line,
final List<String> text)
{
NullCheck.notNull(file, "file");
NullCheck.notNull(text, "text");
if (text.length() == 1) {
try {
return valid(create(Paths.get(text.get(0))));
} catch (final IllegalArgumentException e) {
return errorExpectedGotValidation(file, line, makeSyntax(), text);
}
}
return errorExpectedGotValidation(file, line, makeSyntax(), text);
}
代码示例来源:origin: com.io7m.smfj/com.io7m.smfj.processing.main
final SMFSchemaName schema = SMFSchemaName.of(text.get(0));
final int major = Integer.parseUnsignedInt(text.get(1));
final int minor = Integer.parseUnsignedInt(text.get(2));
return valid(create(
SMFSchemaIdentifier.builder()
代码示例来源:origin: com.io7m.smfj/com.io7m.smfj.processing.main
/**
* Attempt to parse a command.
*
* @param file The file, if any
* @param line The line
* @param text The text
*
* @return A parsed command or a list of parse errors
*/
public static Validation<List<SMFParseError>, SMFMemoryMeshFilterType> parse(
final Optional<URI> file,
final int line,
final List<String> text)
{
NullCheck.notNull(file, "file");
NullCheck.notNull(text, "text");
if (text.length() == 1) {
try {
final SMFAttributeName attr = SMFAttributeName.of(text.get(0));
return Validation.valid(create(attr));
} catch (final IllegalArgumentException e) {
return errorExpectedGotValidation(file, line, makeSyntax(), text);
}
}
return errorExpectedGotValidation(file, line, makeSyntax(), text);
}
内容来源于网络,如有侵权,请联系作者删除!