Ravi Nori has posted comments on this change.

Change subject: engine: Add infrastructure code for removal of parameter classes
......................................................................


Patch Set 2:

(4 comments)

....................................................
File 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/queries/InvalidParameterValueException.java
Line 9: 
Line 10:     /**
Line 11:      * GWT does not support String.format. This class is used by 
frontend code.
Line 12:      */
Line 13:     public static String format(final String format, final String... 
args) {
will do
Line 14:         String[] split = format.split("%s");
Line 15:         final StringBuffer buffer = new StringBuffer();
Line 16:         for (int i = 0; i < split.length - 1; i += 1) {
Line 17:             buffer.append(split[i]);


....................................................
File 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/utils/VdcParameter.java
Line 6: public enum VdcParameter implements IVdcParameter {
Line 7:     ClusterId(Guid.class),
Line 8:     DataCenterId(Guid.class),
Line 9:     RoleId(Guid.class),
Line 10:     StorageDomainId(Guid.class);
I can move it to another enum. But we need at least one instance something like 
(limitation of enum)

public enum VdcParameter implements IVdcParameter {
        Unknown(Void.class);
        ....
}

More over enums cannot extend other classes or other enums, they can only 
implement Interfaces. So every enum should have the methods

@Override
public Class getJavaType() {
        return javaType;        
}

@Override
public String getKey() {
        return this.name();
}

@Override
public String toString() {
        return VdcParameter.class.getName() + "." + super.toString();
}
Line 11: 
Line 12:     private final Class javaType;
Line 13: 
Line 14:     VdcParameter(Class javaType) {


....................................................
File 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/utils/VdcParameterValue.java
Line 2: 
Line 3: import java.io.Serializable;
Line 4: import 
org.ovirt.engine.core.common.queries.InvalidParameterValueException;
Line 5: 
Line 6: public class VdcParameterValue<T> implements Serializable {
I had to add this for Json serialization/desrialization

The recommended way of serializing in Jackson is Collection<VdcParameterValue> 
rather than Map<String, Object>. Serializing/Deserialzing does not work with Map

When we deserialize we rebuild Map<String, VdcParameterValue> from 
Collection<VdcParameterValue>. So we need the key(IVdcParameter) and 
value(Object) to rebuild the map.

If need VdcParameterValue class to support the use case of Json serialization 
and deserialization.
Line 7: 
Line 8:     private IVdcParameter key;
Line 9:     private T value;
Line 10: 


....................................................
File 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/utils/VdcParametersMap.java
Line 19:         VdcParameterValue.raiseExceptionIfInvalidObjectType(param, 
value);
Line 20:         paramsMap.put(param.toString(), new VdcParameterValue(param, 
value));
Line 21:     }
Line 22: 
Line 23:     public Object getParameterValue(String param) {
Will do
Line 24:         return paramsMap.get(param);
Line 25:     }
Line 26:     public Object getParameterValue(IVdcParameter param) {
Line 27:         VdcParameterValue paramValue = paramsMap.get(param.toString());


-- 
To view, visit http://gerrit.ovirt.org/20414
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: I6a0970e492c0eff561888a46b02e47645ff68fc3
Gerrit-PatchSet: 2
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Ravi Nori <rn...@redhat.com>
Gerrit-Reviewer: Alon Bar-Lev <alo...@redhat.com>
Gerrit-Reviewer: Barak Azulay <bazu...@redhat.com>
Gerrit-Reviewer: Ravi Nori <rn...@redhat.com>
Gerrit-Reviewer: oVirt Jenkins CI Server
Gerrit-HasComments: Yes
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to