nus-yam/ex-repair huggingface dataset:
Program: 88957
Project: 88957
Buggy source:
@Override protected String getTypeDefaultValue(){
  Date defaultDate=null;
  if (defaultTime == null) {
    throw new RuntimeException("String_Node_Str");
  }
switch (defaultTime) {
case NOW:
    defaultDate=new Date();
  break;
case EPOCH_0:
defaultDate=new Date(0);
break;
default :
throw new RuntimeException("String_Node_Str");
}
return super.getValueAsString(dateFormat.format(defaultDate));
}

Fixed version (ground truth):
@Override protected String getTypeDefaultValue(){
  if (defaultTime == null) {
    throw new RuntimeException("String_Node_Str");
  }
  Date defaultDate;
switch (defaultTime) {
case NOW:
    defaultDate=new Date();
  break;
case EPOCH_0:
defaultDate=new Date(0);
break;
default :
throw new RuntimeException("String_Node_Str");
}
return super.getValueAsString(dateFormat.format(defaultDate));
}
Program: 88958
Project: 88958
Buggy source:
private Class[] extractGroupsFromAnnotation(Annotation annotation){
  try {
    final Method groupsMethod=annotation.getClass().getMethod(GROUPS_METHOD_NAME);
    final Object result=groupsMethod.invoke(annotation);
    final Class[] annotationGroups=(Class[])result;
    return annotationGroups;
  }
 catch (  NoSuchMethodException e) {
    LOG.warn("String_Node_Str",annotation.getClass().getName());
  }
catch (  InvocationTargetException e) {
    LOG.error("String_Node_Str",e);
  }
catch (  IllegalAccessException e) {
    LOG.error("String_Node_Str",e);
  }
  return new Class[0];
}

Fixed version (ground truth):
private Class[] extractGroupsFromAnnotation(Annotation annotation){
  try {
    final Method groupsMethod=annotation.getClass().getMethod(GROUPS_METHOD_NAME);
    final Object result=groupsMethod.invoke(annotation);
    return (Class[])result;
  }
 catch (  NoSuchMethodException e) {
    LOG.warn("String_Node_Str",annotation.getClass().getName());
  }
catch (  InvocationTargetException e) {
    LOG.error("String_Node_Str",e);
  }
catch (  IllegalAccessException e) {
    LOG.error("String_Node_Str",e);
  }
  return new Class[0];
}
Program: 88959
Project: 88959
Buggy source:
private boolean checkAtLeastRequiredGroups(T[] groupsGiven){
  final Set<T> configuredGroups=new HashSet<T>(groups.size());
  for (  T group : groups) {
    configuredGroups.add(group);
  }
  final int groupsNeededCount=configuredGroups.size();
  final Set<T> givenGroups=new HashSet<T>(groupsGiven.length);
  for (  T group : groupsGiven) {
    givenGroups.add(group);
  }
  final int groupsGivenCount=givenGroups.size();
  if (groupsGivenCount < groupsNeededCount) {
    return false;
  }
  int groupsFoundCount=0;
  for (  T givenGroup : givenGroups) {
    if (configuredGroups.contains(givenGroup)) {
      ++groupsFoundCount;
    }
  }
  return groupsFoundCount == groupsNeededCount;
}

Fixed version (ground truth):
private boolean checkAtLeastRequiredGroups(T[] groupsGiven){
  final Set<T> configuredGroups=new HashSet<T>(groups.size());
  for (  T group : groups) {
    configuredGroups.add(group);
  }
  final int groupsNeededCount=configuredGroups.size();
  final Set<T> givenGroups=new HashSet<T>(groupsGiven.length);
  Collections.addAll(givenGroups,groupsGiven);
  final int groupsGivenCount=givenGroups.size();
  if (groupsGivenCount < groupsNeededCount) {
    return false;
  }
  int groupsFoundCount=0;
  for (  T givenGroup : givenGroups) {
    if (configuredGroups.contains(givenGroup)) {
      ++groupsFoundCount;
    }
  }
  return groupsFoundCount == groupsNeededCount;
}
Program: 88960
Project: 88960
Buggy source:
@Override public void addAnnotationProcessor(ValidationAnnotationProcessor annotationProcessor){
  annotationProcessors.add(annotationProcessor);
  if (annotationProcessor.isBaseValidator()) {
    baseAnnotationProcessors.put(annotationProcessor.getBaseValidatorForClass(),annotationProcessor);
  }
}

Fixed version (ground truth):
@Override public final void addAnnotationProcessor(ValidationAnnotationProcessor annotationProcessor){
  annotationProcessors.add(annotationProcessor);
  if (annotationProcessor.isBaseValidator()) {
    baseAnnotationProcessors.put(annotationProcessor.getBaseValidatorForClass(),annotationProcessor);
  }
}
Program: 88961
Project: 88961
Buggy source:
/** 
 * Sets the class for which this processor acts as a base validator. Once this method is called, the class will act as a base validator and the  {@link fi.vincit.jmobster.processor.defaults.BaseValidationAnnotationProcessor#isBaseValidator()}method will return true.
 * @param baseValidatorForClass Class for which the processor should act as base validator
 */
protected void setBaseValidatorForClass(Class baseValidatorForClass){
  this.baseValidatorForClass=baseValidatorForClass;
}

Fixed version (ground truth):
/** 
 * Sets the class for which this processor acts as a base validator. Once this method is called, the class will act as a base validator and the  {@link fi.vincit.jmobster.processor.defaults.BaseValidationAnnotationProcessor#isBaseValidator()}method will return true.
 * @param baseValidatorForClass Class for which the processor should act as base validator
 */
protected final void setBaseValidatorForClass(Class baseValidatorForClass){
  this.baseValidatorForClass=baseValidatorForClass;
}
Program: 88962
Project: 88962
Buggy source:
@Override public Class[] getGroups(Annotation annotation){
  Class[] groups=getGroupsInternal(annotation);
  return groups != null ? groups : new Class[0];
}

Fixed version (ground truth):
@Override public Class[] getGroups(Annotation annotation){
  Class[] groups=getGroupsInternal(annotation);
  return groups != null ? groups : EMPTY_GROUPS;
}
Program: 88963
Project: 88963
Buggy source:
/** 
 * Sets writer to use
 * @param writer Model writer
 */
public void setWriter(ModelWriter writer){
  this.writer=new JavaScriptWriter(writer);
}

Fixed version (ground truth):
/** 
 * Sets writer to use
 * @param writer Model writer
 */
public final void setWriter(ModelWriter writer){
  this.writer=new JavaScriptWriter(writer);
}
Program: 88964
Project: 88964
Buggy source:
/** 
 * Sets default model writer
 * @param writer Model writer
 */
public void setWriter(ModelWriter writer){
  this.writer=new JavaScriptWriter(writer);
}

Fixed version (ground truth):
/** 
 * Sets default model writer
 * @param writer Model writer
 */
public final void setWriter(ModelWriter writer){
  this.writer=new JavaScriptWriter(writer);
}
Program: 88965
Project: 88965
Buggy source:
/** 
 * Constructs manager with required and optional types.
 * @param requiredTypes Required types
 * @param optionalTypes Optional types
 */
public CombinationManager(RequiredTypes requiredTypes,OptionalTypes optionalTypes){
  this.requiredTypes=requiredTypes;
  this.optionalTypes=optionalTypes;
  this.requiredClasses=new HashMap<Class,Class>();
  for (  Class c : this.requiredTypes.getTypes()) {
    requiredClasses.put(c,c);
  }
  this.optionalClasses=new HashMap<Class,Class>();
  for (  Class c : this.optionalTypes.getTypes()) {
    optionalClasses.put(c,c);
  }
}

Fixed version (ground truth):
/** 
 * Constructs manager with required and optional types.
 * @param requiredTypes Required types
 * @param optionalTypes Optional types
 */
public CombinationManager(RequiredTypes requiredTypes,OptionalTypes optionalTypes){
  this.requiredClasses=new HashMap<Class,Class>();
  for (  Class c : requiredTypes.getTypes()) {
    requiredClasses.put(c,c);
  }
  this.optionalClasses=new HashMap<Class,Class>();
  for (  Class c : optionalTypes.getTypes()) {
    optionalClasses.put(c,c);
  }
}
Program: 88966
Project: 88966
Buggy source:
/** 
 * Write the given string and start new line. If writeSeparator is set to true, also writes the separator right after the modelString. Line change will be performed after modelString and if separator is written, it will be performed after separator.
 * @param modelStringLine String to write
 * @param separator Optional separator to write
 * @param writeSeparator Should separator be written. Set true if should, set false if not.
 * @return
 */
ModelWriter writeLine(String modelStringLine,String separator,boolean writeSeparator);

Fixed version (ground truth):
/** 
 * Write the given string and start new line. If writeSeparator is set to true, also writes the separator right after the modelString. Line change will be performed after modelString and if separator is written, it will be performed after separator.
 * @param modelStringLine String to write
 * @param separator Optional separator to write
 * @param writeSeparator Should separator be written. Set true if should, set false if not.
 * @return Writer for chaining calls.
 */
ModelWriter writeLine(String modelStringLine,String separator,boolean writeSeparator);
Program: 88967
Project: 88967
Buggy source:
public T[] getTypes(){
  if (types != null) {
    return types;
  }
 else {
    return (T[])Array.newInstance(types.getClass(),0);
  }
}

Fixed version (ground truth):
public T[] getTypes(){
  return types;
}
Program: 88968
Project: 88968
Buggy source:
@Test public void testProcessNoValidators() throws Exception {
  ModelWriter writer=mockWriter();
  AnnotationProcessor annotationProcessor=mock(AnnotationProcessor.class);
  ModelNamingStrategy modelNamingStrategy=mock(ModelNamingStrategy.class);
  BackboneValueSectionWriter backboneValueSectionWriter=mock(BackboneValueSectionWriter.class);
  BackboneValidationSectionWriter backboneValidationSectionWriter=mock(BackboneValidationSectionWriter.class);
  BackboneModelProcessor bmp=new BackboneModelProcessor(writer,"String_Node_Str",annotationProcessor,modelNamingStrategy,"String_Node_Str","String_Node_Str",backboneValueSectionWriter,backboneValidationSectionWriter);
  final List<ModelField> fields=new ArrayList<ModelField>();
  final Model testModel=new Model(String.class,fields);
  testModel.setValidations(false);
  bmp.startProcessing();
  bmp.processModel(testModel,false);
  bmp.endProcessing();
  InOrder order=inOrder(writer,annotationProcessor,modelNamingStrategy,backboneValueSectionWriter,backboneValidationSectionWriter);
  order.verify(modelNamingStrategy).getName(testModel);
  order.verify(backboneValueSectionWriter).writeDefaultValues(fields,false);
  order.verify(backboneValidationSectionWriter,times(0)).writeValidators(any(List.class));
}

Fixed version (ground truth):
@Test public void testProcessNoValidators() throws Exception {
  ModelWriter writer=mockWriter();
  AnnotationProcessor annotationProcessor=mock(AnnotationProcessor.class);
  ModelNamingStrategy modelNamingStrategy=mock(ModelNamingStrategy.class);
  BackboneValueSectionWriter backboneValueSectionWriter=mock(BackboneValueSectionWriter.class);
  BackboneValidationSectionWriter backboneValidationSectionWriter=mock(BackboneValidationSectionWriter.class);
  BackboneModelProcessor bmp=new BackboneModelProcessor(writer,annotationProcessor,modelNamingStrategy,"String_Node_Str","String_Node_Str",backboneValueSectionWriter,backboneValidationSectionWriter);
  final List<ModelField> fields=new ArrayList<ModelField>();
  final Model testModel=new Model(String.class,fields);
  testModel.setValidations(false);
  bmp.startProcessing();
  bmp.processModel(testModel,false);
  bmp.endProcessing();
  InOrder order=inOrder(writer,annotationProcessor,modelNamingStrategy,backboneValueSectionWriter,backboneValidationSectionWriter);
  order.verify(modelNamingStrategy).getName(testModel);
  order.verify(backboneValueSectionWriter).writeDefaultValues(fields,false);
  order.verify(backboneValidationSectionWriter,times(0)).writeValidators(any(List.class));
}
Program: 88969
Project: 88969
Buggy source:
@Test public void testProcessWithValidators() throws Exception {
  ModelWriter writer=mockWriter();
  AnnotationProcessor annotationProcessor=mock(AnnotationProcessor.class);
  ModelNamingStrategy modelNamingStrategy=mock(ModelNamingStrategy.class);
  BackboneValueSectionWriter backboneValueSectionWriter=mock(BackboneValueSectionWriter.class);
  BackboneValidationSectionWriter backboneValidationSectionWriter=mock(BackboneValidationSectionWriter.class);
  BackboneModelProcessor bmp=new BackboneModelProcessor(writer,"String_Node_Str",annotationProcessor,modelNamingStrategy,"String_Node_Str","String_Node_Str",backboneValueSectionWriter,backboneValidationSectionWriter);
  final List<ModelField> fields=new ArrayList<ModelField>();
  final Model testModel=new Model(String.class,fields);
  testModel.setValidations(true);
  bmp.startProcessing();
  bmp.processModel(testModel,true);
  bmp.endProcessing();
  InOrder order=inOrder(writer,annotationProcessor,modelNamingStrategy,backboneValueSectionWriter,backboneValidationSectionWriter);
  order.verify(modelNamingStrategy).getName(testModel);
  order.verify(backboneValueSectionWriter).writeDefaultValues(fields,true);
  order.verify(backboneValidationSectionWriter).writeValidators(fields);
}

Fixed version (ground truth):
@Test public void testProcessWithValidators() throws Exception {
  ModelWriter writer=mockWriter();
  AnnotationProcessor annotationProcessor=mock(AnnotationProcessor.class);
  ModelNamingStrategy modelNamingStrategy=mock(ModelNamingStrategy.class);
  BackboneValueSectionWriter backboneValueSectionWriter=mock(BackboneValueSectionWriter.class);
  BackboneValidationSectionWriter backboneValidationSectionWriter=mock(BackboneValidationSectionWriter.class);
  BackboneModelProcessor bmp=new BackboneModelProcessor(writer,annotationProcessor,modelNamingStrategy,"String_Node_Str","String_Node_Str",backboneValueSectionWriter,backboneValidationSectionWriter);
  final List<ModelField> fields=new ArrayList<ModelField>();
  final Model testModel=new Model(String.class,fields);
  testModel.setValidations(true);
  bmp.startProcessing();
  bmp.processModel(testModel,true);
  bmp.endProcessing();
  InOrder order=inOrder(writer,annotationProcessor,modelNamingStrategy,backboneValueSectionWriter,backboneValidationSectionWriter);
  order.verify(modelNamingStrategy).getName(testModel);
  order.verify(backboneValueSectionWriter).writeDefaultValues(fields,true);
  order.verify(backboneValidationSectionWriter).writeValidators(fields);
}
Program: 88970
Project: 88970
Buggy source:
/** 
 * Adds annotation processor to provider.
 * @param annotationProcessor Processor to add
 */
protected void addAnnotationProcessor(ValidationAnnotationProcessor annotationProcessor){
  annotationProcessors.add(annotationProcessor);
  if (annotationProcessor.isBaseValidator()) {
    baseAnnotationProcessors.put(annotationProcessor.getBaseValidatorForClass(),annotationProcessor);
  }
}

Fixed version (ground truth):
@Override public void addAnnotationProcessor(ValidationAnnotationProcessor annotationProcessor){
  annotationProcessors.add(annotationProcessor);
  if (annotationProcessor.isBaseValidator()) {
    baseAnnotationProcessors.put(annotationProcessor.getBaseValidatorForClass(),annotationProcessor);
  }
}
Program: 88971
Project: 88971
Buggy source:
/** 
 * Prepares the processor for writing. Initializes the annotations the processor uses so that they can be found via  {@link BaseValidationAnnotationProcessor#findAnnotation(Class)}.
 * @param annotations Annotations for a field.
 */
private void prepareForWrite(List<Annotation> annotations){
  annotationBag=new HashMap<Class,Annotation>();
  for (  Annotation a : annotations) {
    if (combinationManager.containsClass(a.annotationType())) {
      annotationBag.put(a.annotationType(),a);
    }
  }
}

Fixed version (ground truth):
/** 
 * Prepares the processor for writing. Initializes the annotations the processor uses so that they can be found via  {@link BaseValidationAnnotationProcessor#findAnnotation(Class)}.
 * @param annotations Annotations for a field.
 */
private void prepareForWrite(List<Annotation> annotations){
  annotationBag=new HashMap<Class,Annotation>();
  for (  Annotation annotation : annotations) {
    if (combinationManager.containsClass(annotation.annotationType())) {
      annotationBag.put(annotation.annotationType(),annotation);
    }
  }
}
Program: 88972
Project: 88972
Buggy source:
/** 
 * Constructor for processor required annotations and optional annotations but no type information.
 * @param requiredAnnotation Required annotations
 * @param optionalAnnotations Optional annotations
 */
protected BaseValidationAnnotationProcessor(RequiredTypes requiredAnnotation,OptionalTypes optionalAnnotations){
  this.combinationManager=new CombinationManager(requiredAnnotation,optionalAnnotations);
}

Fixed version (ground truth):
/** 
 * Constructor for processor required annotations and optional annotations but no type information.
 * @param requiredAnnotation Required annotations
 * @param optionalAnnotations Optional annotations
 */
protected BaseValidationAnnotationProcessor(RequiredTypes requiredAnnotation,OptionalTypes optionalAnnotations){
  this.requiredType=null;
  this.combinationManager=new CombinationManager(requiredAnnotation,optionalAnnotations);
}
Program: 88973
Project: 88973
Buggy source:
public BackboneModelProcessor(ModelWriter writer){
  this((String)null,GroupMode.ANY_OF_REQUIRED);
  this.writer=writer;
}

Fixed version (ground truth):
public BackboneModelProcessor(ModelWriter writer,FieldAnnotationWriter fieldAnnotationWriter){
  this((String)null,GroupMode.ANY_OF_REQUIRED,fieldAnnotationWriter);
  this.writer=writer;
}
Program: 88974
Project: 88974
Buggy source:
/** 
 * Checks whether the managers combination matches the given classes combination. The combination matches if and only if the all of the given classes are same set (same classes and count is same).
 * @param classes Classes to check
 * @return True if given classes match required classes, otherwise false.
 */
public boolean matches(List<Annotation> classes){
  int matchesFound=0;
  for (  Annotation c : classes) {
    if (requiredClasses.containsKey(c.annotationType())) {
      ++matchesFound;
    }
  }
  return matchesFound >= requiredClasses.size();
}

Fixed version (ground truth):
/** 
 * Checks whether the managers combination matches the given classes combination. The combination matches if and only if the all of the given classes are same set (same classes and count is same).
 * @param classes Classes to check
 * @return True if given classes match required classes, otherwise false.
 */
public boolean matches(List<Annotation> classes){
  if (requiredClasses.isEmpty() && optionalClasses.isEmpty()) {
    return false;
  }
  int matchesFound=0;
  for (  Annotation c : classes) {
    if (requiredClasses.containsKey(c.annotationType())) {
      ++matchesFound;
    }
  }
  return matchesFound >= requiredClasses.size();
}
Program: 88975
Project: 88975
Buggy source:
@Test public void testSimpleClass(){
  FieldAnnotationWriter app=new BackboneFieldAnnotationWriter();
  DefaultModelGenerator mg=new DefaultModelGenerator(new BackboneModelProcessor(modelWriter),new JavaToJSValueConverter(ConverterMode.ALLOW_NULL),app);
  mg.process(TestModel.class);
  String referenceModel="String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str";
  assertEquals(referenceModel,os.toString());
}

Fixed version (ground truth):
@Test public void testSimpleClass(){
  FieldAnnotationWriter app=new BackboneFieldAnnotationWriter();
  app.addAnnotationProcessor(new NonBaseAnnotationProcessor());
  DefaultModelGenerator mg=new DefaultModelGenerator(new BackboneModelProcessor(modelWriter,app),new JavaToJSValueConverter(ConverterMode.ALLOW_NULL),app);
  mg.process(TestModel.class);
  String referenceModel="String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str";
  assertEquals(referenceModel,os.toString());
}
Program: 88976
Project: 88976
Buggy source:
@Test public void testNoValidationsClass(){
  FieldAnnotationWriter app=new BackboneFieldAnnotationWriter();
  DefaultModelGenerator mg=new DefaultModelGenerator(new BackboneModelProcessor(modelWriter),new JavaToJSValueConverter(ConverterMode.ALLOW_NULL),app);
  mg.process(NoValidationsClass.class);
  String referenceModel="String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str";
  assertEquals(referenceModel,os.toString());
}

Fixed version (ground truth):
@Test public void testNoValidationsClass(){
  FieldAnnotationWriter app=new BackboneFieldAnnotationWriter();
  DefaultModelGenerator mg=new DefaultModelGenerator(new BackboneModelProcessor(modelWriter,app),new JavaToJSValueConverter(ConverterMode.ALLOW_NULL),app);
  mg.process(NoValidationsClass.class);
  String referenceModel="String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str";
  assertEquals(referenceModel,os.toString());
}
Program: 88977
Project: 88977
Buggy source:
public CachedModelProvider(Mode mode){
  this.bos=new ByteOutputStream();
  this.modelWriter=new StreamModelWriter(bos);
switch (mode) {
case COMPACT:
    configureCompactMode(modelWriter);
  break;
case PRETTY:
configurePrettyMode(modelWriter);
break;
}
}

Fixed version (ground truth):
public CachedModelProvider(Mode mode){
  this.bos=new ByteArrayOutputStream();
  this.modelWriter=new StreamModelWriter(bos);
switch (mode) {
case COMPACT:
    configureCompactMode(modelWriter);
  break;
case PRETTY:
configurePrettyMode(modelWriter);
break;
}
}
Program: 88978
Project: 88978
Buggy source:
@Override public void process(Class... classes){
  List<Model> models=getModels(classes);
  try {
    modelProcessor.startProcessing();
    for (int i=0; i < models.size(); ++i) {
      Model model=models.get(i);
      boolean isLastModel=i == models.size() - 1;
      modelProcessor.processModel(model,isLastModel);
    }
    modelProcessor.endProcessing();
  }
 catch (  IOException e) {
    LOG.error("String_Node_Str",e);
  }
}

Fixed version (ground truth):
@Override protected void process(Model model,boolean isLastModel){
  modelProcessor.processModel(model,isLastModel);
}
Program: 88979
Project: 88979
Buggy source:
@Before public void initTest(){
  os=new ByteOutputStream();
  mw=new StreamModelWriter(os);
  writer=new JavaScriptWriter(mw);
}

Fixed version (ground truth):
@Before public void initTest(){
  os=new ByteArrayOutputStream();
  mw=new StreamModelWriter(os);
  writer=new JavaScriptWriter(mw);
}
Program: 88980
Project: 88980
Buggy source:
@Override protected void process(Annotation annotation,boolean isLast){
  ValidationAnnotationProcessor annotationProcessor=annotationProcessorProvider.getValidator(annotation);
  if (annotationProcessor != null) {
    if (annotationProcessor.requiresType()) {
      appendType(hasPropertyTypeSet,writer,annotationProcessor.requiredType());
      hasPropertyTypeSet=true;
    }
    annotationProcessor.writeValidatorsToStream(annotation,writer);
  }
 else {
    LOG.debug("String_Node_Str");
  }
  writer.writeLine("String_Node_Str","String_Node_Str",!isLast);
}

Fixed version (ground truth):
@Override protected void process(Annotation annotation,boolean isLast){
  ValidationAnnotationProcessor annotationProcessor=annotationProcessorProvider.getValidator(annotation);
  if (annotationProcessor != null) {
    if (annotationProcessor.requiresType()) {
      appendType(hasPropertyTypeSet,writer,annotationProcessor.requiredType());
      hasPropertyTypeSet=true;
    }
    annotationProcessor.writeValidatorsToStream(annotation,writer);
    writer.writeLine("String_Node_Str","String_Node_Str",!isLast);
  }
 else {
    LOG.debug("String_Node_Str");
  }
}
Program: 88981
Project: 88981
Buggy source:
@Override public void writeValidation(List<Annotation> validationAnnotations,final ModelWriter writer){
  ItemProcessor<Annotation> annotationItemProcessor=new ItemProcessor<Annotation>(){
    boolean hasPropertyTypeSet=false;
    @Override protected void process(    Annotation annotation,    boolean isLast){
      ValidationAnnotationProcessor annotationProcessor=annotationProcessorProvider.getValidator(annotation);
      if (annotationProcessor != null) {
        if (annotationProcessor.requiresType()) {
          appendType(hasPropertyTypeSet,writer,annotationProcessor.requiredType());
          hasPropertyTypeSet=true;
        }
        annotationProcessor.writeValidatorsToStream(annotation,writer);
      }
 else {
        LOG.debug("String_Node_Str");
      }
      writer.writeLine("String_Node_Str","String_Node_Str",!isLast);
    }
  }
;
  annotationItemProcessor.process(validationAnnotations);
}

Fixed version (ground truth):
@Override public void writeValidation(List<Annotation> validationAnnotations,final ModelWriter writer){
  ItemProcessor<Annotation> annotationItemProcessor=new ItemProcessor<Annotation>(){
    boolean hasPropertyTypeSet=false;
    @Override protected void process(    Annotation annotation,    boolean isLast){
      ValidationAnnotationProcessor annotationProcessor=annotationProcessorProvider.getValidator(annotation);
      if (annotationProcessor != null) {
        if (annotationProcessor.requiresType()) {
          appendType(hasPropertyTypeSet,writer,annotationProcessor.requiredType());
          hasPropertyTypeSet=true;
        }
        annotationProcessor.writeValidatorsToStream(annotation,writer);
        writer.writeLine("String_Node_Str","String_Node_Str",!isLast);
      }
 else {
        LOG.debug("String_Node_Str");
      }
    }
  }
;
  annotationItemProcessor.process(validationAnnotations);
}
Program: 88982
Project: 88982
Buggy source:
@Override public void processModel(Model model,boolean isLastModel){
  String modelName=modelNamingStrategy.getName(model);
  writer.write(modelName).writeLine(MODEL_EXTEND_START).indent();
  DefaultValueSectionWriter defaultValueSectionWriter=new DefaultValueSectionWriter(writer);
  defaultValueSectionWriter.writeDefaultValues(model.getFields(),model.hasValidations());
  ValidationSectionWriter validationSectionWriter=new ValidationSectionWriter(writer,annotationProcessor);
  validationSectionWriter.writeValidators(model.getFields());
  writer.indentBack();
  writer.writeLine(MODEL_EXTEND_END,"String_Node_Str",!isLastModel);
}

Fixed version (ground truth):
@Override public void processModel(Model model,boolean isLastModel){
  String modelName=modelNamingStrategy.getName(model);
  writer.write(modelName).writeLine(MODEL_EXTEND_START).indent();
  DefaultValueSectionWriter defaultValueSectionWriter=new DefaultValueSectionWriter(writer);
  defaultValueSectionWriter.writeDefaultValues(model.getFields(),model.hasValidations());
  if (model.hasValidations()) {
    ValidationSectionWriter validationSectionWriter=new ValidationSectionWriter(writer,annotationProcessor);
    validationSectionWriter.writeValidators(model.getFields());
  }
  writer.indentBack();
  writer.writeLine(MODEL_EXTEND_END,"String_Node_Str",!isLastModel);
}
Program: 88983
Project: 88983
Buggy source:
@Test public void testSimpleClass(){
  DefaultModelGenerator mg=new DefaultModelGenerator(new BackboneModelProcessor(modelWriter),new JavaToJSValueConverter(ConverterMode.ALLOW_NULL));
  mg.process(TestModel.class);
  String referenceModel="String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str";
  assertEquals(referenceModel,os.toString());
}

Fixed version (ground truth):
@Test public void testSimpleClass(){
  DefaultModelGenerator mg=new DefaultModelGenerator(new BackboneModelProcessor(modelWriter),new JavaToJSValueConverter(ConverterMode.ALLOW_NULL));
  mg.process(TestModel.class);
  String referenceModel="String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str";
  assertEquals(referenceModel,os.toString());
}
Program: 88984
Project: 88984
Buggy source:
public BackboneModelProcessor(ModelWriter writer){
  this((String)null);
  this.writer=writer;
}

Fixed version (ground truth):
public BackboneModelProcessor(ModelWriter writer){
  this((String)null,GroupMode.ANY_OF_REQUIRED);
  this.writer=writer;
}
Program: 88985
Project: 88985
Buggy source:
public DefaultAnnotationProcessor(AnnotationProcessorProvider annotationProcessorProvider){
  this.annotationProcessorProvider=annotationProcessorProvider;
}

Fixed version (ground truth):
public DefaultAnnotationProcessor(AnnotationProcessorProvider annotationProcessorProvider,GroupMode groupMode,Class... groups){
  this.annotationProcessorProvider=annotationProcessorProvider;
  this.groups=groups;
  this.groupMode=groupMode;
  this.includeValidationsWithoutGroup=false;
}
Program: 88986
Project: 88986
Buggy source:
@Override public void writeValidation(List<Annotation> validationAnnotations,final JavaScriptWriter writer){
  ItemProcessor<Annotation> annotationItemProcessor=new ItemProcessor<Annotation>(){
    boolean hasPropertyTypeSet=false;
    @Override protected void process(    Annotation annotation,    boolean isLast){
      ValidationAnnotationProcessor annotationProcessor=annotationProcessorProvider.getValidator(annotation);
      if (annotationProcessor != null) {
        if (annotationProcessor.requiresType()) {
          appendType(hasPropertyTypeSet,writer,annotationProcessor.requiredType());
          hasPropertyTypeSet=true;
        }
        annotationProcessor.writeValidatorsToStream(annotation,writer);
        writer.writeLine("String_Node_Str","String_Node_Str",!isLast);
      }
 else {
        LOG.debug("String_Node_Str");
      }
    }
  }
;
  annotationItemProcessor.process(validationAnnotations);
}

Fixed version (ground truth):
@Override public void writeValidation(List<Annotation> validationAnnotations,final JavaScriptWriter writer){
  ItemProcessor<Annotation> annotationItemProcessor=new ItemProcessor<Annotation>(){
    boolean hasPropertyTypeSet=false;
    @Override protected void process(    Annotation annotation,    boolean isLast){
      ValidationAnnotationProcessor annotationProcessor=annotationProcessorProvider.getValidator(annotation);
      if (annotationProcessor != null) {
        if (annotationProcessor.requiresType()) {
          appendType(hasPropertyTypeSet,writer,annotationProcessor.requiredType());
          hasPropertyTypeSet=true;
        }
        annotationProcessor.writeValidatorsToStream(annotation,writer);
        writer.writeLine("String_Node_Str","String_Node_Str",!isLast);
      }
 else {
        LOG.debug("String_Node_Str");
      }
    }
  }
;
  List<Annotation> filteredAnnotations=filterByGroupRules(validationAnnotations);
  annotationItemProcessor.process(filteredAnnotations);
}
Program: 88987
Project: 88987
Buggy source:
@Test public void testMultipleItems(){
}

Fixed version (ground truth):
@Test public void testMultipleItems(){
  List<String> list=new ArrayList<String>();
  list.add("String_Node_Str");
  list.add("String_Node_Str");
  list.add("String_Node_Str");
  list.add("String_Node_Str");
  StringBuilder sb=new StringBuilder();
  LastItemCaller lic=new LastItemCaller();
  ItemProcessor<String> itemProcessor=getItemProcessor(sb,lic);
  itemProcessor.process(list);
  assertEquals("String_Node_Str",sb.toString());
  assertEquals(1,lic.calledWithLastTrue);
  assertEquals(3,lic.calledWithLastFalse);
}
Program: 88988
Project: 88988
Buggy source:
@Test public void testOneItem(){
}

Fixed version (ground truth):
@Test public void testOneItem(){
  List<String> list=new ArrayList<String>();
  list.add("String_Node_Str");
  StringBuilder sb=new StringBuilder();
  LastItemCaller lic=new LastItemCaller();
  ItemProcessor<String> itemProcessor=getItemProcessor(sb,lic);
  itemProcessor.process(list);
  assertEquals("String_Node_Str",sb.toString());
  assertEquals(1,lic.calledWithLastTrue);
  assertEquals(0,lic.calledWithLastFalse);
}
Program: 88989
Project: 88989
Buggy source:
@Test public void testNullItems(){
}

Fixed version (ground truth):
@Test public void testNullItems(){
  List<String> list=null;
  StringBuilder sb=new StringBuilder();
  LastItemCaller lic=new LastItemCaller();
  ItemProcessor<String> itemProcessor=getItemProcessor(sb,lic);
  itemProcessor.process(list);
  assertEquals("String_Node_Str",sb.toString());
  assertEquals(0,lic.calledWithLastTrue);
  assertEquals(0,lic.calledWithLastFalse);
}
Program: 88990
Project: 88990
Buggy source:
@Test public void testNoItems(){
}

Fixed version (ground truth):
@Test public void testNoItems(){
  List<String> list=new ArrayList<String>();
  StringBuilder sb=new StringBuilder();
  LastItemCaller lic=new LastItemCaller();
  ItemProcessor<String> itemProcessor=getItemProcessor(sb,lic);
  itemProcessor.process(list);
  assertEquals("String_Node_Str",sb.toString());
  assertEquals(0,lic.calledWithLastTrue);
  assertEquals(0,lic.calledWithLastFalse);
}
Program: 88991
Project: 88991
Buggy source:
/** 
 * Checks if the field be added to model fields.
 * @param field Field to checks
 * @return True if the field should be included in model fields. Otherwise false.
 */
private boolean shouldAddField(Field field){
  return !field.isAnnotationPresent(IgnoreField.class);
}

Fixed version (ground truth):
/** 
 * Checks if the field be added to model fields.
 * @param field Field to checks
 * @return True if the field should be included in model fields. Otherwise false.
 */
private boolean shouldAddField(Field field){
  return !field.isAnnotationPresent(IgnoreField.class) && (allowStaticFields || !Modifier.isStatic(field.getModifiers())) && (allowFinalFields || !Modifier.isFinal(field.getModifiers()));
}
Program: 88992
Project: 88992
Buggy source:
/** 
 * Creates new field scanner
 * @param fieldDefaultValueProcessor Field default value processor
 * @param annotationProcessorProvider Annotation processor provider
 */
public FieldScanner(FieldValueConverter fieldDefaultValueProcessor,AnnotationProcessorProvider annotationProcessorProvider){
  this.fieldDefaultValueProcessor=fieldDefaultValueProcessor;
  this.annotationProcessorProvider=annotationProcessorProvider;
}

Fixed version (ground truth):
/** 
 * Creates new field scanner
 * @param fieldDefaultValueProcessor Field default value processor
 * @param annotationProcessorProvider Annotation processor provider
 */
public FieldScanner(FieldValueConverter fieldDefaultValueProcessor,AnnotationProcessorProvider annotationProcessorProvider){
  this.fieldDefaultValueProcessor=fieldDefaultValueProcessor;
  this.annotationProcessorProvider=annotationProcessorProvider;
  allowStaticFields=false;
  allowFinalFields=false;
}
Program: 88993
Project: 88993
Buggy source:
private void checkAndSetValidationState(Model model){
  for (  ModelField modelField : model.getFields()) {
    if (modelField.hasValidations()) {
      model.setValidations(true);
      break;
    }
  }
}

Fixed version (ground truth):
/** 
 * Checks and sets the validation state for the given model. If the given model has at least one field that requires validation the model property validations will be set to true. If the model doesn't have any validation requirements the property will be set to false.
 * @param model Model to check
 */
private void checkAndSetValidationState(Model model){
  for (  ModelField modelField : model.getFields()) {
    if (modelField.hasValidations()) {
      model.setValidations(true);
      return;
    }
  }
  model.setValidations(false);
}
Program: 88994
Project: 88994
Buggy source:
public InvalidType(String s,Throwable throwable,boolean b,boolean b1){
  super(s,throwable,b,b1);
}

Fixed version (ground truth):
public InvalidType(Throwable throwable){
  super(throwable);
}
Program: 88995
Project: 88995
Buggy source:
public UnsupportedFramework(String s,Throwable throwable,boolean b,boolean b1){
  super(s,throwable,b,b1);
}

Fixed version (ground truth):
public UnsupportedFramework(Throwable throwable){
  super(throwable);
}
Program: 88996
Project: 88996
Buggy source:
public TestModel(){
  longList.add(1L);
  longList.add(100L);
}

Fixed version (ground truth):
public TestModel(){
  longList.add(1L);
  longList.add(100L);
  intStringMap.put(1,"String_Node_Str");
  intStringMap.put(2,"String_Node_Str");
  intStringMap.put(100,"String_Node_Str");
}
Program: 88997
Project: 88997
Buggy source:
@Override public String convertValue(Object value){
  return convertArrayFromObject(value);
}

Fixed version (ground truth):
@Override public String convertValue(Object values){
  if (values == null) {
    return getTypeDefaultValue();
  }
  return convertArrayFromObject(values);
}
Program: 88998
Project: 88998
Buggy source:
@Override public String convertValue(Object values){
  Collection collectionObject=(Collection)values;
  StringBuilder sb=new StringBuilder();
  sb.append("String_Node_Str");
  final int size=collectionObject.size();
  int i=0;
  for (  Object value : collectionObject) {
    String convertedValue=javaToJSValueConverter.convert(value.getClass(),value);
    sb.append(convertedValue);
    if (i != size - 1) {
      sb.append("String_Node_Str");
    }
    ++i;
  }
  sb.append("String_Node_Str");
  return sb.toString();
}

Fixed version (ground truth):
@Override public String convertValue(Object values){
  if (values == null) {
    return getTypeDefaultValue();
  }
  Collection collectionObject=(Collection)values;
  StringBuilder sb=new StringBuilder();
  sb.append("String_Node_Str");
  final int size=collectionObject.size();
  int i=0;
  for (  Object value : collectionObject) {
    String convertedValue=javaToJSValueConverter.convert(value.getClass(),value);
    sb.append(convertedValue);
    if (i != size - 1) {
      sb.append("String_Node_Str");
    }
    ++i;
  }
  sb.append("String_Node_Str");
  return sb.toString();
}
Program: 88999
Project: 88999
Buggy source:
@Override public String convertValue(Object values){
  Map<Object,Object> map=(Map)values;
  StringBuilder sb=new StringBuilder();
  sb.append("String_Node_Str");
  final int size=map.size();
  int i=0;
  for (  Map.Entry<Object,Object> entry : map.entrySet()) {
    Object key=entry.getKey();
    Object value=entry.getValue();
    String convertedKey=javaToJSValueConverter.convert(key.getClass(),key);
    String convertedValue=getEntryValue(value);
    sb.append(convertedKey).append("String_Node_Str");
    sb.append(convertedValue);
    if (i != size - 1) {
      sb.append("String_Node_Str");
    }
    ++i;
  }
  sb.append("String_Node_Str");
  return sb.toString();
}

Fixed version (ground truth):
@Override public String convertValue(Object values){
  if (values == null) {
    return getTypeDefaultValue();
  }
  Map<Object,Object> map=(Map)values;
  StringBuilder sb=new StringBuilder();
  sb.append("String_Node_Str");
  final int size=map.size();
  int i=0;
  for (  Map.Entry<Object,Object> entry : map.entrySet()) {
    Object key=entry.getKey();
    Object value=entry.getValue();
    String convertedKey=javaToJSValueConverter.convert(key.getClass(),key);
    String convertedValue=getEntryValue(value);
    sb.append(convertedKey).append("String_Node_Str");
    sb.append(convertedValue);
    if (i != size - 1) {
      sb.append("String_Node_Str");
    }
    ++i;
  }
  sb.append("String_Node_Str");
  return sb.toString();
}
Program: 89000
Project: 89000
Buggy source:
public int getStorageCount(ItemStack storage,ItemStack addition,boolean allowPartial){
  if (addition == null)   return 0;
 else   if (storage == null)   return addition.getAmount();
 else   if (storage.getType() != Material.AIR && !hasSameItem(storage,addition))   return 0;
  int sum=storage.getAmount() + addition.getAmount();
  int max=storage.getType().getMaxStackSize();
  if (sum > max) {
    return allowPartial ? max - storage.getAmount() : 0;
  }
 else {
    return addition.getAmount();
  }
}

Fixed version (ground truth):
public int getStorageCount(ItemStack storage,ItemStack addition,boolean allowPartial){
  boolean isAir=storage == null || storage.getType() == Material.AIR;
  if (addition == null)   return 0;
 else   if (storage == null)   return addition.getAmount();
 else   if (!isAir && !hasSameItem(storage,addition))   return 0;
  int sum=storage.getAmount() + addition.getAmount();
  int max=isAir ? addition.getMaxStackSize() : storage.getMaxStackSize();
  if (sum > max) {
    return allowPartial ? max - storage.getAmount() : 0;
  }
 else {
    return addition.getAmount();
  }
}
Program: 89002
Project: 89002
Buggy source:
/** 
 * Determines if the given action has any rewards or messages.
 * @return
 */
public boolean hasNothing(ChannelProvider provider){
  List<String> channels=getChannels(provider,message);
  return rewards.isEmpty() && (channels == null || channels.isEmpty());
}

Fixed version (ground truth):
/** 
 * Determines if the given action has any rewards or messages.
 * @return
 */
public boolean hasNothing(ChannelProvider provider){
  return rewards.isEmpty() && (message == null || getChannels(provider,message) == null);
}
Program: 89004
Project: 89004
Buggy source:
private void initializeReferences(){
  if (rewardProvider != null) {
    rewardProvider=rewardProvider.createView(this);
  }
  if (channelProvider != null) {
    channelProvider=channelProvider.createView();
  }
  if (messageQueue != null) {
    messageQueue=messageQueue.createView();
  }
  if (actionParser != null) {
    actionParser=actionParser.createView(rewardProvider);
  }
}

Fixed version (ground truth):
private void initializeReferences(){
  if (rewardProvider != null) {
    rewardProvider=rewardProvider.createView(this);
  }
  if (channelProvider != null) {
    channelProvider=channelProvider.createView();
  }
  if (messageQueue != null) {
    messageQueue=messageQueue.createView();
    messageQueue.setChannelProvider(channelProvider);
  }
  if (actionParser != null) {
    actionParser=actionParser.createView(rewardProvider);
  }
}
Program: 89006
Project: 89006
Buggy source:
/** 
 * Retrieves the default service, or the next non-disabled service if  the default service is disabled.
 * @return The default service, or NULL if not found.
 */
public TService getDefaultService(){
  TService service=getByName(getDefaultName());
  if (isEnabled(service))   return service;
 else   return Iterables.getFirst(getEnabledServices(),null);
}

Fixed version (ground truth):
/** 
 * Retrieves the default service, or the next non-disabled service if  the default service is disabled.
 * @return The default service, or NULL if not found.
 */
public TService getDefaultService(){
  TService service=getByName(getDefaultName());
  if (service != null && isEnabled(service))   return service;
 else   return Iterables.getFirst(getEnabledServices(),null);
}
Program: 89007
Project: 89007
Buggy source:
public ServiceProvider(String defaultName){
  this.defaultName=defaultName;
}

Fixed version (ground truth):
/** 
 * Copy everything from the given provider.
 * @param other - the given provider.
 */
public ServiceProvider(ServiceProvider<TService> other){
  this.defaultName=other.defaultName;
  this.nameLookup=new ConcurrentHashMap<String,TService>(other.nameLookup);
  this.disabledLookup=Sets.newSetFromMap(new ConcurrentHashMap<String,Boolean>());
  for (  String disabled : other.disabledLookup) {
    this.disabledLookup.add(disabled);
  }
}