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

org.sfm.reflect.meta.TupleClassMeta Maven / Gradle / Ivy

package org.sfm.reflect.meta;

import org.sfm.map.MapperBuildingException;
import org.sfm.reflect.ConstructorDefinition;
import org.sfm.reflect.ReflectionService;

import java.lang.reflect.Type;
import java.util.Collections;
import java.util.List;

public class TupleClassMeta implements ClassMeta {

	private final ReflectionService reflectionService;
	private Type type;
	private List> constructorDefinitions;

	public TupleClassMeta(Type type, ReflectionService reflectionService) {
		this.type = type;
		this.reflectionService = reflectionService;

		try {
			this.constructorDefinitions = reflectionService.extractConstructors(type);
		} catch(Exception e) {
			throw new MapperBuildingException(e.getMessage(), e);
		}
	}


	@Override
	public ReflectionService getReflectionService() {
		return reflectionService;
	}

	@Override
	public PropertyFinder newPropertyFinder() {
		return new TuplePropertyFinder(this);
	}

	public Type getType() {
		return type;
	}


	public List> getConstructorDefinitions() {
		return constructorDefinitions;
	}

	public int getTupleSize() {
		return constructorDefinitions.get(0).getParameters().length;
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy