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


Java StringValue类代码示例

本文整理汇总了Java中graphql.language.StringValue的典型用法代码示例。如果您正苦于以下问题:Java StringValue类的具体用法?Java StringValue怎么用?Java StringValue使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


StringValue类属于graphql.language包,在下文中一共展示了StringValue类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: parseLiteral

import graphql.language.StringValue; //导入依赖的package包/类
@Override
public ZonedDateTime parseLiteral(Object input) {
    if (input instanceof StringValue) {
        return ZonedDateTime.parse(((StringValue) input).getValue());
    } else if (input instanceof IntValue) {
        return Instant.ofEpochMilli(((IntValue) input).getValue().longValue()).atZone(ZoneOffset.UTC);
    } else {
        return null;
    }
}
 
开发者ID:howtographql,项目名称:graphql-java,代码行数:11,代码来源:Scalars.java

示例2: getInstant

import graphql.language.StringValue; //导入依赖的package包/类
private Instant getInstant(Object input) {
    if (input instanceof Instant) {
        return (Instant) input;
    } else if (input instanceof String) {
        return Instant.parse((String) input);
    } else if (input instanceof StringValue) {
        return Instant.parse(((StringValue) input).getValue());
    }

    return null;
}
 
开发者ID:merapar,项目名称:graphql-spring-boot-starter,代码行数:12,代码来源:Scalars.java

示例3: getDuration

import graphql.language.StringValue; //导入依赖的package包/类
private Duration getDuration(Object input) {
    if (input instanceof Duration) {
        return (Duration) input;
    } else if (input instanceof String) {
        return Duration.parse((String) input);
    } else if (input instanceof StringValue) {
        return Duration.parse(((StringValue) input).getValue());
    }
    return null;
}
 
开发者ID:merapar,项目名称:graphql-spring-boot-starter,代码行数:11,代码来源:Scalars.java

示例4: instant_Serialize_StringValue

import graphql.language.StringValue; //导入依赖的package包/类
@Test
public void instant_Serialize_StringValue() {
    // Given
    val input = new StringValue("2016-11-21T06:00:00Z");

    // When
    val parseResult = Scalars.GraphQlInstant.getCoercing().serialize(input);

    // Then
    assertThat(parseResult).isEqualTo(LocalDateTime.of(2016, 11, 21, 6, 0).toInstant(ZoneOffset.UTC));
}
 
开发者ID:merapar,项目名称:graphql-spring-boot-starter,代码行数:12,代码来源:ScalarsTest.java

示例5: instant_ParseLiteral_WrongStringInput_ShouldThrowDateTimeParseException

import graphql.language.StringValue; //导入依赖的package包/类
@Test
public void instant_ParseLiteral_WrongStringInput_ShouldThrowDateTimeParseException() {
    // Given
    val input = new StringValue("2016-11-21T06:00:");

    // When
    val parseExcpetion = assertThatThrownBy(() -> Scalars.GraphQlInstant.getCoercing().parseLiteral(input));

    // Then
    parseExcpetion.isExactlyInstanceOf(DateTimeParseException.class).hasMessage("Text '2016-11-21T06:00:' could not be parsed at index 17");
}
 
开发者ID:merapar,项目名称:graphql-spring-boot-starter,代码行数:12,代码来源:ScalarsTest.java

示例6: duration_Serialize_StringValue

import graphql.language.StringValue; //导入依赖的package包/类
@Test
public void duration_Serialize_StringValue() {
    // Given
    val input = new StringValue("PT48H");

    // When
    val parseResult = Scalars.GraphQlDuration.getCoercing().serialize(input);

    // Then
    assertThat(parseResult).isEqualTo(Duration.ofHours(48));
}
 
开发者ID:merapar,项目名称:graphql-spring-boot-starter,代码行数:12,代码来源:ScalarsTest.java

示例7: duration_ParseLiteral_WrongStringInput_ShouldThrowDateTimeException

import graphql.language.StringValue; //导入依赖的package包/类
@Test
public void duration_ParseLiteral_WrongStringInput_ShouldThrowDateTimeException() {
    // Given
    val input = new StringValue("P48H");

    // When
    val parseExcpetion = assertThatThrownBy(() -> Scalars.GraphQlDuration.getCoercing().parseLiteral(input));

    // Then
    parseExcpetion.isExactlyInstanceOf(DateTimeParseException.class).hasMessage("Text cannot be parsed to a Duration");
}
 
开发者ID:merapar,项目名称:graphql-spring-boot-starter,代码行数:12,代码来源:ScalarsTest.java

示例8: testStringTemporal

import graphql.language.StringValue; //导入依赖的package包/类
private void testStringTemporal(Class type, Coercing coercing, String expected) {
    Object parsed = coercing.parseLiteral(new StringValue(expected));
    assertTrue(type.isInstance(parsed));
    assertEquals(expected, coercing.serialize(parsed));

    parsed = coercing.parseValue(expected);
    assertTrue(type.isInstance(parsed));
    assertEquals(expected, coercing.serialize(parsed));
    
    Object same = coercing.parseValue(parsed);
    assertEquals(parsed, same);
}
 
开发者ID:leangen,项目名称:graphql-spqr,代码行数:13,代码来源:ScalarsTest.java

示例9: parseLiteral

import graphql.language.StringValue; //导入依赖的package包/类
@Override
public Date parseLiteral(Object o) {
    Object input;
    if (o instanceof IntValue) {
        input = ((IntValue) o).getValue().longValue();
    } else if (o instanceof StringValue) {
        input = ((StringValue) o).getValue();
    } else {
        throw new CoercingParseValueException(ERROR_BAD_EPOCH_TYPE);
    }
    return parseValue(input);
}
 
开发者ID:yahoo,项目名称:elide,代码行数:13,代码来源:GraphQLScalars.java

示例10: parseLiteral

import graphql.language.StringValue; //导入依赖的package包/类
@Override
public Object parseLiteral(Object input) {
    if (input instanceof StringValue) {
        return parseStringToLocalDateTime(((StringValue) input).getValue());
    } else if (input instanceof IntValue) {
        BigInteger value = ((IntValue) input).getValue();
        return parseLongToLocalDateTime(value.longValue());
    }
    return null;
}
 
开发者ID:jcrygier,项目名称:graphql-jpa,代码行数:11,代码来源:JavaScalars.java

示例11: getDirectiveArgument

import graphql.language.StringValue; //导入依赖的package包/类
public Optional<String> getDirectiveArgument(GraphQLObjectType parentType, String directiveName,
                                                  String argumentName) {
  return Optional.ofNullable(parentType.getDefinition().getDirective(directiveName))
    .map(d -> d.getArgument(argumentName))
    .map(v -> (StringValue) v.getValue())
    .map(StringValue::getValue);
}
 
开发者ID:HuygensING,项目名称:timbuctoo,代码行数:8,代码来源:SerializerExecutionStrategy.java

示例12: parseLiteral

import graphql.language.StringValue; //导入依赖的package包/类
@Override
public Object parseLiteral(Object input) {
    if (!(input instanceof StringValue)) return null;
    return UUID.fromString(((StringValue) input).getValue());
}
 
开发者ID:leangen,项目名称:graphql-spqr,代码行数:6,代码来源:Scalars.java

示例13: parseLiteral

import graphql.language.StringValue; //导入依赖的package包/类
@Override
public Object parseLiteral(Object input) {
    if (!(input instanceof StringValue)) return null;
    return new Date(Long.parseLong(((StringValue) input).getValue()));
}
 
开发者ID:oembedler,项目名称:spring-graphql-common,代码行数:6,代码来源:MappingConstants.java

示例14: testGraphQLDateParseLiteral

import graphql.language.StringValue; //导入依赖的package包/类
@Test
public void testGraphQLDateParseLiteral() {
    Date date = new Date(123L);
    assertEquals(GraphQLScalars.GRAPHQL_DATE_TYPE.getCoercing().parseLiteral(new StringValue("123")), date);
    assertEquals(GraphQLScalars.GRAPHQL_DATE_TYPE.getCoercing().parseLiteral(new IntValue(new BigInteger("123"))), date);
}
 
开发者ID:yahoo,项目名称:elide,代码行数:7,代码来源:GraphQLScalarsTest.java

示例15: testGraphQLDeferredIdParseLiteral

import graphql.language.StringValue; //导入依赖的package包/类
@Test
public void testGraphQLDeferredIdParseLiteral() {
    assertEquals(GraphQLScalars.GRAPHQL_DEFERRED_ID.getCoercing().parseLiteral(new IntValue(new BigInteger("123"))), "123");
    assertEquals(GraphQLScalars.GRAPHQL_DEFERRED_ID.getCoercing().parseLiteral(new StringValue("123")), "123");
}
 
开发者ID:yahoo,项目名称:elide,代码行数:6,代码来源:GraphQLScalarsTest.java


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