All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.blazebit.query.connector.gcp.base.GcpConventionContext Maven / Gradle / Ivy

The newest version!
/*
 * SPDX-License-Identifier: Apache-2.0
 * Copyright Blazebit
 */
package com.blazebit.query.connector.gcp.base;

import com.blazebit.query.connector.base.ConventionContext;
import com.google.protobuf.ByteString;

import java.lang.reflect.Member;
import java.lang.reflect.Method;

/**
 * A method filter to exclude internal and cyclic methods from the GCP models.
 *
 * @author Christian Beikov
 * @since 1.0.0
 */
public class GcpConventionContext implements ConventionContext {

	public static final ConventionContext INSTANCE = new GcpConventionContext();

	private GcpConventionContext() {
	}

	@Override
	public ConventionContext getSubFilter(Class concreteClass, Member member) {
		final Method method = (Method) member;
		if ( method.getReturnType() == ByteString.class
				|| method.getName().endsWith( "OrBuilder" )
				|| method.getName().endsWith( "OrBuilderList" )
				|| method.getDeclaringClass().getPackageName().startsWith( "com.google.protobuf" ) ) {
			return null;
		}
		switch ( method.getName() ) {
			case "getDefaultInstanceForType":
			case "getParserForType":
			case "getSerializedSize":
				return null;
			default:
				return this;
		}
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy