Search in sources :

Example 46 with Type

use of com.acgist.snail.pojo.bean.M3u8.Type in project tomee by apache.

the class ReturnValidationGenerator method generateMethods.

protected void generateMethods(final ClassWriter cw) {
    for (final MethodConstraints methodConstraints : constraints) {
        final Method method = methodConstraints.getMethod();
        final String name = method.getName();
        // Declare a method of return type JsonWebToken for use with
        // a call to BeanValidation's ExecutableValidator.validateReturnValue
        final Type returnType = Type.getReturnType(method);
        final Type[] parameterTypes = Type.getArgumentTypes(method);
        final String descriptor = Type.getMethodDescriptor(returnType, parameterTypes);
        final MethodVisitor mv = cw.visitMethod(ACC_PUBLIC, name, descriptor, null, null);
        // Put the method name on the
        final AnnotationVisitor av = mv.visitAnnotation(Type.getDescriptor(Generated.class), true);
        av.visit("value", this.getClass().getName());
        av.visitEnd();
        // track the MethodVisitor
        // We will later copy over the annotations
        generatedMethods.put(method.getName() + Type.getMethodDescriptor(method), new ConstrainedMethodVisitor(mv, methodConstraints));
        if (method.getReturnType().equals(Void.TYPE)) {
            mv.visitCode();
            mv.visitInsn(RETURN);
            mv.visitMaxs(0, 1);
        } else if (method.getReturnType().equals(Long.TYPE)) {
            mv.visitCode();
            mv.visitInsn(LCONST_0);
            mv.visitInsn(LRETURN);
            mv.visitMaxs(2, 4);
            mv.visitEnd();
        } else if (method.getReturnType().equals(Float.TYPE)) {
            mv.visitCode();
            mv.visitInsn(FCONST_0);
            mv.visitInsn(FRETURN);
            mv.visitMaxs(1, 3);
            mv.visitEnd();
        } else if (method.getReturnType().equals(Double.TYPE)) {
            mv.visitCode();
            mv.visitInsn(DCONST_0);
            mv.visitInsn(DRETURN);
            mv.visitMaxs(2, 4);
            mv.visitEnd();
        } else if (method.getReturnType().isPrimitive()) {
            mv.visitCode();
            mv.visitInsn(ICONST_0);
            mv.visitInsn(IRETURN);
            mv.visitMaxs(1, 3);
            mv.visitEnd();
        } else {
            // The method will simply return null
            mv.visitCode();
            mv.visitInsn(ACONST_NULL);
            mv.visitInsn(ARETURN);
            mv.visitMaxs(1, 1);
        }
    }
}
Also used : Type(org.apache.xbean.asm9.Type) AnnotationVisitor(org.apache.xbean.asm9.AnnotationVisitor) Method(java.lang.reflect.Method) MethodVisitor(org.apache.xbean.asm9.MethodVisitor)

Example 47 with Type

use of com.acgist.snail.pojo.bean.M3u8.Type in project java-spanner by googleapis.

the class RandomResultSetGenerator method generate.

public ResultSet generate() {
    ResultSet.Builder builder = ResultSet.newBuilder();
    for (int row = 0; row < rowCount; row++) {
        ListValue.Builder rowBuilder = ListValue.newBuilder();
        for (Type type : TYPES) {
            Value.Builder valueBuilder = Value.newBuilder();
            setRandomValue(valueBuilder, type);
            rowBuilder.addValues(valueBuilder.build());
        }
        builder.addRows(rowBuilder.build());
    }
    builder.setMetadata(METADATA);
    return builder.build();
}
Also used : StructType(com.google.spanner.v1.StructType) Type(com.google.spanner.v1.Type) ListValue(com.google.protobuf.ListValue) ResultSet(com.google.spanner.v1.ResultSet) ListValue(com.google.protobuf.ListValue) NullValue(com.google.protobuf.NullValue) Value(com.google.protobuf.Value)

Example 48 with Type

use of com.acgist.snail.pojo.bean.M3u8.Type in project java-spanner by googleapis.

the class RandomResultSetGenerator method generate.

public ResultSet generate() {
    ResultSet.Builder builder = ResultSet.newBuilder();
    for (int row = 0; row < rowCount; row++) {
        ListValue.Builder rowBuilder = ListValue.newBuilder();
        for (Type type : TYPES) {
            Value.Builder valueBuilder = Value.newBuilder();
            setRandomValue(valueBuilder, type);
            rowBuilder.addValues(valueBuilder.build());
        }
        builder.addRows(rowBuilder.build());
    }
    builder.setMetadata(METADATA);
    return builder.build();
}
Also used : StructType(com.google.spanner.v1.StructType) Type(com.google.spanner.v1.Type) ListValue(com.google.protobuf.ListValue) ResultSet(com.google.spanner.v1.ResultSet) ListValue(com.google.protobuf.ListValue) NullValue(com.google.protobuf.NullValue) Value(com.google.protobuf.Value)

Example 49 with Type

use of com.acgist.snail.pojo.bean.M3u8.Type in project java-spanner by googleapis.

the class SpannerClientTest method partitionQueryExceptionTest.

@Test
public void partitionQueryExceptionTest() throws Exception {
    StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
    mockSpanner.addException(exception);
    try {
        PartitionQueryRequest request = PartitionQueryRequest.newBuilder().setSession(SessionName.of("[PROJECT]", "[INSTANCE]", "[DATABASE]", "[SESSION]").toString()).setTransaction(TransactionSelector.newBuilder().build()).setSql("sql114126").setParams(Struct.newBuilder().build()).putAllParamTypes(new HashMap<String, Type>()).setPartitionOptions(PartitionOptions.newBuilder().build()).build();
        client.partitionQuery(request);
        Assert.fail("No exception raised");
    } catch (InvalidArgumentException e) {
    // Expected exception.
    }
}
Also used : Type(com.google.spanner.v1.Type) InvalidArgumentException(com.google.api.gax.rpc.InvalidArgumentException) PartitionQueryRequest(com.google.spanner.v1.PartitionQueryRequest) StatusRuntimeException(io.grpc.StatusRuntimeException) ByteString(com.google.protobuf.ByteString) Test(org.junit.Test)

Example 50 with Type

use of com.acgist.snail.pojo.bean.M3u8.Type in project java-spanner by googleapis.

the class SpannerClientTest method executeSqlExceptionTest.

@Test
public void executeSqlExceptionTest() throws Exception {
    StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
    mockSpanner.addException(exception);
    try {
        ExecuteSqlRequest request = ExecuteSqlRequest.newBuilder().setSession(SessionName.of("[PROJECT]", "[INSTANCE]", "[DATABASE]", "[SESSION]").toString()).setTransaction(TransactionSelector.newBuilder().build()).setSql("sql114126").setParams(Struct.newBuilder().build()).putAllParamTypes(new HashMap<String, Type>()).setResumeToken(ByteString.EMPTY).setPartitionToken(ByteString.EMPTY).setSeqno(109325920).setQueryOptions(ExecuteSqlRequest.QueryOptions.newBuilder().build()).setRequestOptions(RequestOptions.newBuilder().build()).build();
        client.executeSql(request);
        Assert.fail("No exception raised");
    } catch (InvalidArgumentException e) {
    // Expected exception.
    }
}
Also used : Type(com.google.spanner.v1.Type) ExecuteSqlRequest(com.google.spanner.v1.ExecuteSqlRequest) InvalidArgumentException(com.google.api.gax.rpc.InvalidArgumentException) StatusRuntimeException(io.grpc.StatusRuntimeException) ByteString(com.google.protobuf.ByteString) Test(org.junit.Test)

Aggregations

Type (com.google.api.expr.v1alpha1.Type)30 Test (org.junit.Test)16 Type (edu.stanford.CVC4.Type)14 Type (com.google.spanner.v1.Type)12 ArrayType (edu.stanford.CVC4.ArrayType)11 BitVectorType (edu.stanford.CVC4.BitVectorType)11 Expr (edu.stanford.CVC4.Expr)11 MapType (com.google.api.expr.v1alpha1.Type.MapType)10 Type (org.apache.xbean.asm9.Type)10 ByteString (com.google.protobuf.ByteString)9 CVC4.vectorExpr (edu.stanford.CVC4.vectorExpr)9 ArrayList (java.util.ArrayList)9 CheckedExpr (com.google.api.expr.v1alpha1.CheckedExpr)8 FieldType (org.projectnessie.cel.common.types.ref.FieldType)8 FormulaType (org.sosy_lab.java_smt.api.FormulaType)8 ListValue (com.google.protobuf.ListValue)7 ExecuteSqlRequest (com.google.spanner.v1.ExecuteSqlRequest)7 CheckerEnv.dynElementType (org.projectnessie.cel.checker.CheckerEnv.dynElementType)7 CheckerEnv.getObjectWellKnownType (org.projectnessie.cel.checker.CheckerEnv.getObjectWellKnownType)7 CheckerEnv.isObjectWellKnownType (org.projectnessie.cel.checker.CheckerEnv.isObjectWellKnownType)7