io.permazen.PermazenFieldSwitch Maven / Gradle / Ivy
Show all versions of permazen-main Show documentation
/*
* Copyright (C) 2015 Archie L. Cobbs. All rights reserved.
*/
package io.permazen;
/**
* Visitor pattern interface for {@link PermazenField}s.
*
* @param switch method return type
* @see PermazenField#visit
*/
public interface PermazenFieldSwitch {
/**
* Handle a {@link PermazenSetField}.
*
*
* The implementation in {@link PermazenFieldSwitch} delegates to
* {@link #casePermazenCollectionField casePermazenCollectionField()}.
*
* @param field the visiting field
* @return visitor return value
*/
default R casePermazenSetField(PermazenSetField field) {
return this.casePermazenCollectionField(field);
}
/**
* Handle a {@link PermazenListField}.
*
*
* The implementation in {@link PermazenFieldSwitch} delegates to
* {@link #casePermazenCollectionField casePermazenCollectionField()}.
*
* @param field the visiting field
* @return visitor return value
*/
default R casePermazenListField(PermazenListField field) {
return this.casePermazenCollectionField(field);
}
/**
* Handle a {@link PermazenMapField}.
*
*
* The implementation in {@link PermazenFieldSwitch} delegates to {@link #casePermazenComplexField casePermazenComplexField()}.
*
* @param field the visiting field
* @return visitor return value
*/
default R casePermazenMapField(PermazenMapField field) {
return this.casePermazenComplexField(field);
}
/**
* Handle a {@link PermazenSimpleField}.
*
*
* The implementation in {@link PermazenFieldSwitch} delegates to {@link #casePermazenField casePermazenField()}.
*
* @param field the visiting field
* @return visitor return value
*/
default R casePermazenSimpleField(PermazenSimpleField field) {
return this.casePermazenField(field);
}
/**
* Handle a {@link PermazenReferenceField}.
*
*
* The implementation in {@link PermazenFieldSwitch} delegates to {@link #casePermazenSimpleField casePermazenSimpleField()}.
*
* @param field the visiting field
* @return visitor return value
*/
default R casePermazenReferenceField(PermazenReferenceField field) {
return this.casePermazenSimpleField(field);
}
/**
* Handle a {@link PermazenEnumField}.
*
*
* The implementation in {@link PermazenFieldSwitch} delegates to {@link #casePermazenSimpleField casePermazenSimpleField()}.
*
* @param field the visiting field
* @return visitor return value
*/
default R casePermazenEnumField(PermazenEnumField field) {
return this.casePermazenSimpleField(field);
}
/**
* Handle a {@link PermazenEnumArrayField}.
*
*
* The implementation in {@link PermazenFieldSwitch} delegates to {@link #casePermazenSimpleField casePermazenSimpleField()}.
*
* @param field the visiting field
* @return visitor return value
*/
default R casePermazenEnumArrayField(PermazenEnumArrayField field) {
return this.casePermazenSimpleField(field);
}
/**
* Handle a {@link PermazenCounterField}.
*
*
* The implementation in {@link PermazenFieldSwitch} delegates to {@link #casePermazenField casePermazenField()}.
*
* @param field the visiting field
* @return visitor return value
*/
default R casePermazenCounterField(PermazenCounterField field) {
return this.casePermazenField(field);
}
/**
* Visitor pattern roll-up method.
*
*
* The implementation in {@link PermazenFieldSwitch} delegates to {@link #casePermazenComplexField casePermazenComplexField()}.
*
* @param field the visiting field
* @return visitor return value
*/
default R casePermazenCollectionField(PermazenCollectionField field) {
return this.casePermazenComplexField(field);
}
/**
* Visitor pattern roll-up method.
*
*
* The implementation in {@link PermazenFieldSwitch} delegates to {@link #casePermazenField casePermazenField()}.
*
* @param field the visiting field
* @return visitor return value
*/
default R casePermazenComplexField(PermazenComplexField field) {
return this.casePermazenField(field);
}
/**
* Visitor pattern roll-up method.
*
*
* The implementation in {@link PermazenFieldSwitch} always throws {@link UnsupportedOperationException}.
*
* @param field the visiting field
* @return visitor return value
*/
default R casePermazenField(PermazenField field) {
throw new UnsupportedOperationException(String.format("field type not handled: %s", field));
}
}