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);
}
}
}
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();
}
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();
}
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.
}
}
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.
}
}
Aggregations