
org.codegeny.beans.diff.BeanDiff Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of codegeny-beans Show documentation
Show all versions of codegeny-beans Show documentation
Library which provides meta-model, diffs, paths... for java beans
/*-
* #%L
* codegeny-beans
* %%
* Copyright (C) 2016 - 2018 Codegeny
* %%
* 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.
* #L%
*/
package org.codegeny.beans.diff;
import java.util.Map;
import static java.util.Collections.unmodifiableMap;
import static java.util.Objects.requireNonNull;
/**
* Implementation of {@link Diff}
for beans.
*
* @param The type of bean.
* @author Xavier DURY
*/
public final class BeanDiff extends AbstractDiff {
private static final long serialVersionUID = 1L;
private final Map> properties;
BeanDiff(Status status, B left, B right, Map> properties) {
super(requireNonNull(properties, "Properties cannot be null").values(), status, left, right);
this.properties = unmodifiableMap(properties);
}
/**
* {@inheritDoc}
*/
@Override
public R accept(DiffVisitor visitor) {
return visitor.visitBean(this);
}
/**
* Get the map of diff'ed properties.
*
* @return The properties.
*/
public Map> getProperties() {
return properties;
}
/**
* Get the diff'ed for the given property name.
*
* @param name The property name.
* @return That property's diff.
*/
public Diff> getProperty(String name) {
return properties.get(name);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy