Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
This software is licensed under the Apache 2 license, quoted below. Copyright 2010 Julien Eluard Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at [http://www.apache.org/licenses/LICENSE-2.0] Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
 
 
 package org.semver.jardiff;
 
 import java.util.Set;
 
 
 public final class DifferenceAccumulatingHandler extends AbstractDiffHandler {
     
     private String currentClassName;
     private final Set<Stringincludes;
     private final Set<Stringexcludes;
     private final Set<Differencedifferences = new HashSet<Difference>();
 
     public DifferenceAccumulatingHandler() {
         this(Collections.<String>emptySet(), Collections.<String>emptySet());
     }
 
     public DifferenceAccumulatingHandler(@Nonnull final Set<Stringincludes, @Nonnull final Set<Stringexcludes) {
         this. = includes;
         this. = excludes;
     }
 
     public String getCurrentClassName() {
         return this.;
     }
     
     @Override
     public void startDiff(final String previousfinal String currentthrows DiffException {
     }
 
     @Override
     public void endDiff() throws DiffException {
     }
 
     @Override
     public void startOldContents() throws DiffException {
     }
 
     @Override
     public void endOldContents() throws DiffException {
     }
 
     @Override
     public void startNewContents() throws DiffException {
     }
 
     @Override
     public void endNewContents() throws DiffException {
     }
 
     @Override
     public void contains(final ClassInfo classInfothrows DiffException {
     }
 
     @Override
     public void startAdded() throws DiffException {
     }
 
     @Override
     public void classAdded(final ClassInfo classInfothrows DiffException {
         if (!isConsidered()) {
             return;
         }
 
        this..add(new Add(getClassName(classInfo.getName()), classInfo));
    }
    @Override
    public void fieldAdded(final FieldInfo fieldInfothrows DiffException {
        if (!isConsidered()) {
            return;
        }
        this..add(new Add(getCurrentClassName(), fieldInfo));
    }
    @Override
    public void methodAdded(final MethodInfo methodInfothrows DiffException {
        if (!isConsidered()) {
            return;
        }
        this..add(new Add(getCurrentClassName(), methodInfo));
    }
    @Override
    public void endAdded() throws DiffException {
    }
    @Override
    public void startChanged() throws DiffException {
    }
    @Override
    public void startClassChanged(final String classNamethrows DiffException {
        this. = getClassName(className);
    }
    @Override
    public void classChanged(final ClassInfo oldClassInfofinal ClassInfo newClassInfothrows DiffException {
        if (!isConsidered()) {
            return;
        }
        this..add(new Change(getClassName(oldClassInfo.getName()), oldClassInfonewClassInfo));
    }
    @Override
    public void fieldChanged(final FieldInfo oldFieldInfofinal FieldInfo newFieldInfothrows DiffException {
        if (!isConsidered()) {
            return;
        }
        this..add(new Change(getCurrentClassName(), oldFieldInfonewFieldInfo));
    }
    @Override
    public void methodChanged(final MethodInfo oldMethodInfofinal MethodInfo newMethodInfothrows DiffException {
        if (!isConsidered()) {
            return;
        }
        this..add(new Change(getCurrentClassName(), oldMethodInfonewMethodInfo));
    }
    @Override
    public void endClassChanged() throws DiffException {
    }
    @Override
    public void endChanged() throws DiffException {
    }
    @Override
    public void startRemoved() throws DiffException {
    }
    @Override
    public void classRemoved(final ClassInfo classInfothrows DiffException {
        if (!isConsidered()) {
            return;
        }
        this..add(new Remove(getClassName(classInfo.getName()), classInfo));
    }
    @Override
    public void fieldRemoved(final FieldInfo fieldInfothrows DiffException {
        if (!isConsidered()) {
            return;
        }
        this..add(new Remove(getCurrentClassName(), fieldInfo));
    }
    @Override
    public void methodRemoved(final MethodInfo methodInfothrows DiffException {
        if (!isConsidered()) {
            return;
        }
        this..add(new Remove(getCurrentClassName(), methodInfo));
    }
    @Override
    public void endRemoved() throws DiffException {
    }

    
Is considered a class whose package: * is included * is not excluded If includes are provided then package must be defined here.

Returns:
    private boolean isConsidered() {
        for (final String exclude : this.) {
            if (getCurrentClassName().startsWith(exclude)) {
                return false;
            }
        }
        if (!this..isEmpty()) {
            for (final String include : this.) {
                if (getCurrentClassName().startsWith(include)) {
                    return true;
                }
            }
            return false;
        }
        return true;
    }
    public Delta getDelta() {
        return new Delta(this.);
    }
New to GrepCode? Check out our FAQ X