io.permazen.change.ChangeAdapter Maven / Gradle / Ivy
Show all versions of permazen-main Show documentation
/*
* Copyright (C) 2015 Archie L. Cobbs. All rights reserved.
*/
package io.permazen.change;
/**
* Adpater class for the {@link ChangeSwitch} interface.
*
* @param method return type
*/
public class ChangeAdapter implements ChangeSwitch {
/**
* Handle a {@link ObjectCreate} event.
*
*
* The implementation in {@link ChangeAdapter} delegates to {@link #caseChange caseChange()}.
*/
@Override
public R caseObjectCreate(ObjectCreate change) {
return this.caseChange(change);
}
/**
* Handle a {@link ObjectDelete} event.
*
*
* The implementation in {@link ChangeAdapter} delegates to {@link #caseChange caseChange()}.
*/
@Override
public R caseObjectDelete(ObjectDelete change) {
return this.caseChange(change);
}
/**
* Handle a {@link ListFieldAdd} event.
*
*
* The implementation in {@link ChangeAdapter} delegates to {@link #caseListFieldChange caseListFieldChange()}.
*/
@Override
public R caseListFieldAdd(ListFieldAdd change) {
return this.caseListFieldChange(change);
}
/**
* Handle a {@link ListFieldClear} event.
*
*
* The implementation in {@link ChangeAdapter} delegates to {@link #caseListFieldChange caseListFieldChange()}.
*/
@Override
public R caseListFieldClear(ListFieldClear change) {
return this.caseListFieldChange(change);
}
/**
* Handle a {@link ListFieldRemove} event.
*
*
* The implementation in {@link ChangeAdapter} delegates to {@link #caseListFieldChange caseListFieldChange()}.
*/
@Override
public R caseListFieldRemove(ListFieldRemove change) {
return this.caseListFieldChange(change);
}
/**
* Handle a {@link ListFieldReplace} event.
*
*
* The implementation in {@link ChangeAdapter} delegates to {@link #caseListFieldChange caseListFieldChange()}.
*/
@Override
public R caseListFieldReplace(ListFieldReplace change) {
return this.caseListFieldChange(change);
}
/**
* Handle a {@link MapFieldAdd} event.
*
*
* The implementation in {@link ChangeAdapter} delegates to {@link #caseMapFieldChange caseMapFieldChange()}.
*/
@Override
public R caseMapFieldAdd(MapFieldAdd change) {
return this.caseMapFieldChange(change);
}
/**
* Handle a {@link MapFieldClear} event.
*
*
* The implementation in {@link ChangeAdapter} delegates to {@link #caseMapFieldChange caseMapFieldChange()}.
*/
@Override
public R caseMapFieldClear(MapFieldClear change) {
return this.caseMapFieldChange(change);
}
/**
* Handle a {@link MapFieldRemove} event.
*
*
* The implementation in {@link ChangeAdapter} delegates to {@link #caseMapFieldChange caseMapFieldChange()}.
*/
@Override
public R caseMapFieldRemove(MapFieldRemove change) {
return this.caseMapFieldChange(change);
}
/**
* Handle a {@link MapFieldReplace} event.
*
*
* The implementation in {@link ChangeAdapter} delegates to {@link #caseMapFieldChange caseMapFieldChange()}.
*/
@Override
public R caseMapFieldReplace(MapFieldReplace change) {
return this.caseMapFieldChange(change);
}
/**
* Handle a {@link SetFieldAdd} event.
*
*
* The implementation in {@link ChangeAdapter} delegates to {@link #caseSetFieldChange caseSetFieldChange()}.
*/
@Override
public R caseSetFieldAdd(SetFieldAdd change) {
return this.caseSetFieldChange(change);
}
/**
* Handle a {@link SetFieldClear} event.
*
*
* The implementation in {@link ChangeAdapter} delegates to {@link #caseSetFieldChange caseSetFieldChange()}.
*/
@Override
public R caseSetFieldClear(SetFieldClear change) {
return this.caseSetFieldChange(change);
}
/**
* Handle a {@link SetFieldRemove} event.
*
*
* The implementation in {@link ChangeAdapter} delegates to {@link #caseSetFieldChange caseSetFieldChange()}.
*/
@Override
public R caseSetFieldRemove(SetFieldRemove change) {
return this.caseSetFieldChange(change);
}
/**
* Handle a {@link SimpleFieldChange} event.
*
*
* The implementation in {@link ChangeAdapter} delegates to {@link #caseSetFieldChange caseFieldChange()}.
*/
@Override
public R caseSimpleFieldChange(SimpleFieldChange change) {
return this.caseFieldChange(change);
}
// Roll-Up Methods
/**
* Internal roll-up method.
*
*
* The implementation in {@link ChangeAdapter} delegates to {@link #caseFieldChange caseFieldChange()}.
*
* @param change visiting change
* @param changed object type
* @return visitor return value
*/
protected R caseListFieldChange(ListFieldChange change) {
return this.caseFieldChange(change);
}
/**
* Internal roll-up method.
*
*
* The implementation in {@link ChangeAdapter} delegates to {@link #caseFieldChange caseFieldChange()}.
*
* @param change visiting change
* @param changed object type
* @return visitor return value
*/
protected R caseMapFieldChange(MapFieldChange change) {
return this.caseFieldChange(change);
}
/**
* Internal roll-up method.
*
*
* The implementation in {@link ChangeAdapter} delegates to {@link #caseFieldChange caseFieldChange()}.
*
* @param change visiting change
* @param changed object type
* @return visitor return value
*/
protected R caseSetFieldChange(SetFieldChange change) {
return this.caseFieldChange(change);
}
/**
* Internal roll-up method.
*
*
* The implementation in {@link ChangeAdapter} delegates to {@link #caseChange caseChange()}.
*
* @param change visiting change
* @param changed object type
* @return visitor return value
*/
protected R caseFieldChange(FieldChange change) {
return this.caseChange(change);
}
/**
* Internal roll-up method.
*
*
* The implementation in {@link ChangeAdapter} returns null.
*
* @param change visiting change
* @param changed object type
* @return visitor return value
*/
protected R caseChange(Change change) {
return null;
}
}