Buggy code:
public class IndexTemplateMetaData extends AbstractClusterStatePart implements MapItemClusterStatePart { public static String TYPE = "index_template" ; public static IndexTemplateMetaData . Factory FACTORY = new IndexTemplateMetaData . Factory ( ) ; private final String name ; private final int order ; private final String template ; private final Settings settings ; private final ImmutableOpenMap < String , CompressedString > mappings ; private final ImmutableOpenMap < String , AliasMetaData > aliases ; private final ImmutableOpenMap < String , IndexMetaData . Custom > customs ; public IndexTemplateMetaData ( String name , int order , String template , Settings settings , ImmutableOpenMap < String , CompressedString > mappings , ImmutableOpenMap < String , AliasMetaData > aliases , ImmutableOpenMap < String , IndexMetaData . Custom > customs ) { } public String name ( ) { } public int order ( ) { } public int getOrder ( ) { } public String getName ( ) { } public String template ( ) { } public String getTemplate ( ) { } public Settings settings ( ) { } public Settings getSettings ( ) { } public ImmutableOpenMap < String , CompressedString > mappings ( ) { } public ImmutableOpenMap < String , CompressedString > getMappings ( ) { } public ImmutableOpenMap < String , AliasMetaData > aliases ( ) { } public ImmutableOpenMap < String , AliasMetaData > getAliases ( ) { } public ImmutableOpenMap < String , IndexMetaData . Custom > customs ( ) { } public ImmutableOpenMap < String , IndexMetaData . Custom > getCustoms ( ) { } @ SuppressWarnings ( "unchecked" ) public < T extends Custom > T custom ( String type ) { } public static IndexTemplateMetaData . Builder builder ( String name ) { } @ Override public boolean equals ( Object o ) { } @ Override public int hashCode ( ) { } public static class Builder { private static final Set < String > VALID_FIELDS = Sets . newHashSet ( "template" , "order" , "mappings" , "settings" ) ; private String name ; private int order ; private String template ; private Settings settings = ImmutableSettings . Builder . EMPTY_SETTINGS ; private final ImmutableOpenMap . Builder < String , CompressedString > mappings ; private final ImmutableOpenMap . Builder < String , AliasMetaData > aliases ; private final ImmutableOpenMap . Builder < String , IndexMetaData . Custom > customs ; public Builder ( String name ) { } public Builder ( IndexTemplateMetaData indexTemplateMetaData ) { } public IndexTemplateMetaData . Builder order ( int order ) { } public IndexTemplateMetaData . Builder template ( String template ) { } public String template ( ) { } public IndexTemplateMetaData . Builder settings ( Settings . Builder settings ) { } public IndexTemplateMetaData . Builder settings ( Settings settings ) { } public IndexTemplateMetaData . Builder removeMapping ( String mappingType ) { } public IndexTemplateMetaData . Builder putMapping ( String mappingType , CompressedString mappingSource ) throws IOException { } public IndexTemplateMetaData . Builder putMapping ( String mappingType , String mappingSource ) throws IOException { } public IndexTemplateMetaData . Builder putAlias ( AliasMetaData aliasMetaData ) { } public IndexTemplateMetaData . Builder putAlias ( AliasMetaData . Builder aliasMetaData ) { } public IndexTemplateMetaData . Builder putCustom ( String type , IndexMetaData . Custom customIndexMetaData ) { } public IndexTemplateMetaData . Builder removeCustom ( String type ) { } public Custom getCustom ( String type ) { } public IndexTemplateMetaData build ( ) { } @ SuppressWarnings ( "unchecked" ) public static void toXContent ( IndexTemplateMetaData indexTemplateMetaData , XContentBuilder builder , ToXContent . Params params ) throws IOException { } public static IndexTemplateMetaData fromXContent ( XContentParser parser , String templateName ) throws IOException { } private static String skipTemplateName ( XContentParser parser ) throws IOException { } public static IndexTemplateMetaData readFrom ( StreamInput in ) throws IOException { } public static void writeTo ( IndexTemplateMetaData indexTemplateMetaData , StreamOutput out ) throws IOException { } } @ Override public String key ( ) { <START_BUG> return template ; <END_BUG> } @ Override public void writeTo ( StreamOutput out ) throws IOException { } @ Override public XContentBuilder toXContent ( XContentBuilder builder , Params params ) throws IOException { } public static class Factory extends AbstractClusterStatePart . AbstractFactory < IndexTemplateMetaData > { @ Override public IndexTemplateMetaData readFrom ( StreamInput in , LocalContext context ) throws IOException { } @ Override public IndexTemplateMetaData fromXContent ( XContentParser parser , LocalContext context ) throws IOException { } } }

Fix:
return name ;