@Test public void testProcessEqualsAndHashCode() { MethodSpec.Builder equalsBuilder = MethodSpec.methodBuilder("equals") .addModifiers(Modifier.PUBLIC) .returns(boolean.class) .addAnnotation(Override.class) .addParameter(Object.class, "o"); MethodSpec.Builder hashCodeBuilder = MethodSpec.methodBuilder("hashCode") .addModifiers(Modifier.PUBLIC) .returns(int.class) .addAnnotation(Override.class); List<String> fields = Arrays.asList("one", "two"); MetaInfo metaInfo = new MetaInfo("Test", "com.flipkart.lyrics"); DefaultStyle style = new DefaultStyle(); style.processEqualsAndHashCode(equalsBuilder, hashCodeBuilder, fields, metaInfo, true); }
@Override public void processEqualsAndHashCode(MethodSpec.Builder equalsBuilder, MethodSpec.Builder hashCodeBuilder, List<String> nonStaticFields, MetaInfo metaInfo, boolean testSuperEquality) { equalsBuilder.addComment("Currently not supported."); equalsBuilder.addStatement("return false"); hashCodeBuilder.addComment("Currently not supported."); hashCodeBuilder.addStatement("return 0"); }
DefaultStyle extends ObjectMethodsStyle { @Override public void processEqualsAndHashCode(MethodSpec.Builder equalsBuilder, MethodSpec.Builder hashCodeBuilder, List<String> nonStaticFields, MetaInfo metaInfo, boolean testSuperEquality) { equalsBuilder.addComment("Currently not supported."); equalsBuilder.addStatement("return false"); hashCodeBuilder.addComment("Currently not supported."); hashCodeBuilder.addStatement("return 0"); } }
DefaultStyle extends ObjectMethodsStyle { @Override public void processEqualsAndHashCode(MethodSpec.Builder equalsBuilder, MethodSpec.Builder hashCodeBuilder, List<String> nonStaticFields, MetaInfo metaInfo, boolean testSuperEquality) { equalsBuilder.addComment("Currently not supported."); equalsBuilder.addStatement("return false"); hashCodeBuilder.addComment("Currently not supported."); hashCodeBuilder.addStatement("return 0"); }  }
DefaultStyle extends ObjectMethodsStyle { @Override public void processEqualsAndHashCode(MethodSpec.Builder equalsBuilder, MethodSpec.Builder hashCodeBuilder, List<String> nonStaticFields, MetaInfo metaInfo, boolean testSuperEquality) { equalsBuilder.addComment("Currently not supported."); equalsBuilder.addStatement("return false"); hashCodeBuilder.addComment("Currently not supported."); hashCodeBuilder.addStatement("return 0"); }  @Override void processToString(MethodSpec.Builder toStringBuilder, List<String> nonStaticFields, MetaInfo metaInfo); @Override void processEqualsAndHashCode(MethodSpec.Builder equalsBuilder, MethodSpec.Builder hashCodeBuilder, List<String> nonStaticFields, MetaInfo metaInfo, boolean testSuperEquality); }
DefaultStyle extends ObjectMethodsStyle { @Override public void processEqualsAndHashCode(MethodSpec.Builder equalsBuilder, MethodSpec.Builder hashCodeBuilder, List<String> nonStaticFields, MetaInfo metaInfo, boolean testSuperEquality) { equalsBuilder.addComment("Currently not supported."); equalsBuilder.addStatement("return false"); hashCodeBuilder.addComment("Currently not supported."); hashCodeBuilder.addStatement("return 0"); }  @Override void processToString(MethodSpec.Builder toStringBuilder, List<String> nonStaticFields, MetaInfo metaInfo); @Override void processEqualsAndHashCode(MethodSpec.Builder equalsBuilder, MethodSpec.Builder hashCodeBuilder, List<String> nonStaticFields, MetaInfo metaInfo, boolean testSuperEquality);  }