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

pocketknife.internal.codegen.MethodBinding Maven / Gradle / Ivy

There is a newer version: 3.2.1
Show newest version
package pocketknife.internal.codegen;

import com.squareup.javapoet.MethodSpec;

import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;

public abstract class MethodBinding {

    public abstract List getFields();

    public abstract Set getKeys();

    public abstract MethodSpec generateMethodSpec(TypeUtil typeUtil);

    protected String getReturnVarName(String returnVarNameRoot) {
        Set fieldNames = new LinkedHashSet();
        for (FieldBinding fieldBinding : getFields()) {
            fieldNames.add(fieldBinding.getName());
        }

        String returnVarName = returnVarNameRoot;
        int count = 0;
        while (fieldNames.contains(returnVarName)) {
            returnVarName = returnVarNameRoot + ++count;
        }
        return returnVarName;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy