Skip to content

Adding Diffing Feature #35

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,273 @@
#*
* Copyright 2017-2019 Michael Hoffer <[email protected]>. All rights reserved.
* Copyright 2017-2019 Goethe Center for Scientific Computing, University Frankfurt. All rights reserved.
*
* 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.
*
* If you use this software for scientific research then please cite the following publication(s):
*
* M. Hoffer, C. Poliwoda, & G. Wittum. (2013). Visual reflection library:
* a framework for declarative GUI programming on the Java platform.
* Computing and Visualization in Science, 2013, 16(4),
* 181–192. http://doi.org/10.1007/s00791-014-0230-y
*#
package ${type.implementation.packageName};

// vmf imports
#set($VMFPKG="${VMF_RUNTIME_API_PKG}.${VMF_CORE_PKG_EXT}")
#set($VMFPKG_INT="${VMF_RUNTIME_API_PKG}.${VMF_CORE_PKG_EXT}.internal")
// import ${VMF_RUNTIME_API_PKG}.${VMF_CORE_PKG_EXT}.*;
// import ${VMF_RUNTIME_API_PKG}.${VMF_CORE_PKG_EXT}.internal.*;
//import ${VCOLL_PKG}.*;
import ${type.packageName}.*;
//import java.beans.PropertyChangeSupport;
//import java.beans.PropertyChangeListener;
//import java.util.Objects;
//import java.util.Arrays;

// property types imports
#foreach( $import in $type.implementation.imports )
import $import;
#end

// implementation

/**
* An implementation of the immutable model object {@code $type.fullTypeName}.
*/
@SuppressWarnings("deprecation")
public class $type.implementation.typeName implements $type.typeName, ${VMFPKG}.VObject, ${VMFPKG_INT}.VObjectInternal, VCloneableInternal {

// --------------------------------------------------------------------
// --- declaration of member variables
// --------------------------------------------------------------------

#parse("${VMF_TEMPLATE_PATH}impl/declare-props.vm")

#parse("${VMF_TEMPLATE_PATH}impl/declare-delegates.vm")

// referenced by
private final ${VCOLL_PKG}.VList<${VMFPKG}.VObject> referencedBy = ${VCOLL_PKG}.VList.newInstance(new java.util.ArrayList<>());
// references
private final ${VCOLL_PKG}.VList<${VMFPKG}.VObject> references = ${VCOLL_PKG}.VList.newInstance(new java.util.ArrayList<>());

// --------------------------------------------------------------------
// --- private constructor
// --------------------------------------------------------------------

private ${type.implementation.typeName}() {
// ...
}

// --------------------------------------------------------------------
// --- public getter methods for accessing properties
// --------------------------------------------------------------------

##parse("${VMF_TEMPLATE_PATH}impl/getter.vm")
#foreach( $prop in ${type.implementation.properties} )
@Override
public $prop.getterDeclaration {
#if($prop.propType == "COLLECTION")
if(this.__vmf_prop_$prop.name==null) {
this.__vmf_prop_${prop.name} = ${VCOLL_PKG}.VList.newInstance(
java.util.Collections.emptyList();
);
}
#else## if is collection type
return this.__vmf_prop_${prop.name};
#end## if is collection type
}
#end##foreach property

// --------------------------------------------------------------------
// --- Object methods (equals(), toString() etc.)
// --------------------------------------------------------------------

#parse("${VMF_TEMPLATE_PATH}impl/to-string.vm")

#parse("${VMF_TEMPLATE_PATH}impl/equals.vm")

public $type.typeName clone() {
// we don't need to perform actual cloning since this is an
// immutable type
return this;
}

#parse("${VMF_TEMPLATE_PATH}impl/builder.vm")

#parse("${VMF_TEMPLATE_PATH}impl/delegation-methods.vm")

// --------------------------------------------------------------------
// --- Utility methods
// --------------------------------------------------------------------

@Override
public void addPropertyChangeListener(java.beans.PropertyChangeListener l) {
// don't do anything. immutable types don't publish change events
}
@Override
public void removePropertyChangeListener(java.beans.PropertyChangeListener l) {
// don't do anything. immutable types don't publish change events
}

private boolean _vmf_hasListeners() {
return false;
}

/*package private*/ void _vmf_firePropertyChangeIfListenersArePresent() {
// don't do anything. immutable types don't publish change events
}

@Override
public ${type.typeName} _vmf_deepCopy(
java.util.IdentityHashMap<Object,Object> identityMap) {
return this;
}

@Override
public ${type.typeName} _vmf_shallowCopy(
java.util.IdentityHashMap<Object,Object> identityMap) {
return this;
}

// --------------------------------------------------------------------
// --- Public VMF API
// --------------------------------------------------------------------

private ${VMFPKG}.VMF vmf;

@Override
public ${VMFPKG}.VMF vmf() {
if(vmf==null) {
vmf = new ${VMFPKG}.VMF() {
public ${VMFPKG}.Content content() {
return new ${VMFPKG}.Content() {
public ${VMFPKG}.VIterator iterator() {
return ${VMFPKG}.VIterator.of(${type.implementation.typeName}.this);
}
public java.util.stream.Stream<${VMFPKG}.VObject> stream() {
return ${VMFPKG}.VIterator.of(${type.implementation.typeName}.this).asStream();
}

public ${VMFPKG}.VIterator iterator(${VMFPKG}.VIterator.IterationStrategy strategy) {
return ${VMFPKG}.VIterator.of(${type.implementation.typeName}.this, strategy);
}
public java.util.stream.Stream<${VMFPKG}.VObject> stream(${VMFPKG}.VIterator.IterationStrategy strategy) {
return ${VMFPKG}.VIterator.of(${type.implementation.typeName}.this, strategy).asStream();
}
public <T extends ${VMFPKG}.VObject> java.util.stream.Stream<T> stream(Class<T> type) {
return stream().filter(e->type.isAssignableFrom(e.getClass())).map(e->(T)e);
}
public <T extends ${VMFPKG}.VObject> java.util.stream.Stream<T> stream(Class<T> type, ${VMFPKG}.VIterator.IterationStrategy strategy) {
return stream(strategy).filter(e->type.isAssignableFrom(e.getClass())).map(e->(T)e);
}
public ${VCOLL_PKG}.VList<${VMFPKG}.VObject> referencedBy() {
return _vmf_referencedBy().asUnmodifiable();
}
public ${VCOLL_PKG}.VList<${VMFPKG}.VObject> references() {
return _vmf_references().asUnmodifiable();
}

@Override
public ${type.typeName} deepCopy() {
java.util.IdentityHashMap<Object,Object> identityMap =
new java.util.IdentityHashMap<>();
return _vmf_deepCopy(identityMap);
}

@Override
public ${type.typeName} shallowCopy() {
// we don't copy anything since this is an immutable type
return ${type.implementation.typeName}.this;
}
};
}

private ${VMFPKG_INT}.ChangesImpl changes;

public ${VMFPKG}.Changes changes() {
if (changes==null) {
changes = new ${VMFPKG_INT}.ChangesImpl();
changes.setModel(${type.implementation.typeName}.this);
}

return changes;
}

private ${VMFPKG_INT}.ReflectImpl reflect;

public ${VMFPKG}.Reflect reflect() {
if (reflect==null) {
reflect = new ${VMFPKG_INT}.ReflectImpl();
reflect.setModel(${type.implementation.typeName}.this);
}

return reflect;
}

}; // end vmf
} // end if null

return vmf;
}

@Override
public ${type.typeName} asReadOnly() {
return this;
}

// Type info
@Override
public ${VMF_RUNTIME_API_PKG}.${VMF_CORE_PKG_EXT}.Type _vmf_getType() {
return ${type.packageName}.${type.typeName}.type();
}

// --------------------------------------------------------------------
// --- Reflection methods
// --------------------------------------------------------------------

// type id for improved reflection performance
public static final int _VMF_TYPE_ID = $type.typeId;

@Override
public int _vmf_getTypeId() {
return _VMF_TYPE_ID;
}

#set($readOnlyVal=true)
#parse("${VMF_TEMPLATE_PATH}reflection/reflection.vm")

// --------------------------------------------------------------------
// --- Id related methods
// --------------------------------------------------------------------

// id management is currently not part of VMF (TODO how should we support this?)

// --------------------------------------------------------------------
// --- Reference methods
// --------------------------------------------------------------------

@Override
public ${VCOLL_PKG}.VList<${VMFPKG}.VObject> _vmf_referencedBy() {
// TODO 17.02.2019 feature deactivated due to huge memory consumption
// return this.referencedBy;
throw new UnsupportedOperationException("TODO 17.02.2019 feature deactivated due to huge memory consumption");
}
@Override
public ${VCOLL_PKG}.VList<${VMFPKG}.VObject> _vmf_references() {
// TODO 17.02.2019 feature deactivated due to huge memory consumption
// return this.references;
throw new UnsupportedOperationException("TODO 17.02.2019 feature deactivated due to huge memory consumption");
}

}
Loading