src/main/java/tinyrtpl/Data.java
private boolean compareTo(Data d) {
        if(d != null && d.type < this.type) return d.compareTo(this);
        switch (this.type) {
            case 1:
                if(d == null) return !this.vboolean;
                return (d.toBoolean() == this.vboolean);
            case 2:
                if(d == null) return this.vint == 0;
                switch (d.type) {
                    case 2:
                        return this.vint == d.vint;
                    case 3:
                        return d.vfloat == (double)this.vint;
                    case 4:
                        try {
                            int id = Integer.parseInt(d.vstring);
                            return this.vint == id;
                        } catch (NumberFormatException ex) {
                            if("".equals(d.vstring)) return this.vint == 0;
                            return false;
                        }
                    case 5:
                        return this.vint == 0 && d.vmap == null;
                    case 6:
                        return this.vint == 0 && d.varray == null;
                }
            case 3:
                if(d == null) return this.vfloat == 0;
                switch (d.type) {
                    case 3:
                        return this.vfloat == d.vfloat;
                    case 4:
                        Object nd = d.toNumber();
                        if(nd instanceof Integer || nd instanceof Double)
                            return this.vfloat == (Double) nd;
                        return false;
                    case 5:
                        return this.vfloat == 0 && d.vmap == null;
                    case 6:
                        return this.vfloat == 0 && d.varray == null;
                }
            case 4:
                if(d == null) return "".equals(this.vstring);
                switch (d.type) {
                    case 4:
                        return this.vstring.equals(d.vstring);
                    case 5:
                        return "".equals(this.vstring) && d.vmap == null;
                    case 6:
                        return "".equals(this.vstring) && d.varray == null;
                }
            case 5:
                if(d == null) return this.vmap == null;
                switch (d.type) {
                    case 5:
                        if(this.vmap == null) return d.vmap == null;
                        if(d.vmap == null) return false;
                        if(this.vmap.size() == 0 && d.vmap.size() == 0) return true;
                        return this.vmap == d.vmap; //TODO: deep compare
                    case 6:
                        if(this.vmap == null) return d.varray == null;
                        return false;
                }
            case 6:
                if(d == null) return this.varray == null;
                switch (d.type) {
                    case 6:
                        if(this.varray == null) return d.varray == null;
                        if(d.varray == null) return false;
                        if(this.varray.size() == 0 && d.varray.size() == 0) return true;
                        return this.varray == d.varray; //TODO: deep compare
                }
        }
        return false;
    }
/**
     * Compare with another instance.
     * @param d: a Data instance
     * @return true or false
     */
Compare with another instance.
@param d: a Data instance
@return true or false
Compare with another instance . @param d : a Data instance @return true or false
private boolean compareTo(Data d) {
        if(d != null && d.type < this.type) return d.compareTo(this);
        switch (this.type) {
            case 1:
                if(d == null) return !this.vboolean;
                return (d.toBoolean() == this.vboolean);
            case 2:
                if(d == null) return this.vint == 0;
                switch (d.type) {
                    case 2:
                        return this.vint == d.vint;
                    case 3:
                        return d.vfloat == (double)this.vint;
                    case 4:
                        try {
                            int id = Integer.parseInt(d.vstring);
                            return this.vint == id;
                        } catch (NumberFormatException ex) {
                            if("".equals(d.vstring)) return this.vint == 0;
                            return false;
                        }
                    case 5:
                        return this.vint == 0 && d.vmap == null;
                    case 6:
                        return this.vint == 0 && d.varray == null;
                }
            case 3:
                if(d == null) return this.vfloat == 0;
                switch (d.type) {
                    case 3:
                        return this.vfloat == d.vfloat;
                    case 4:
                        Object nd = d.toNumber();
                        if(nd instanceof Integer || nd instanceof Double)
                            return this.vfloat == (Double) nd;
                        return false;
                    case 5:
                        return this.vfloat == 0 && d.vmap == null;
                    case 6:
                        return this.vfloat == 0 && d.varray == null;
                }
            case 4:
                if(d == null) return "".equals(this.vstring);
                switch (d.type) {
                    case 4:
                        return this.vstring.equals(d.vstring);
                    case 5:
                        return "".equals(this.vstring) && d.vmap == null;
                    case 6:
                        return "".equals(this.vstring) && d.varray == null;
                }
            case 5:
                if(d == null) return this.vmap == null;
                switch (d.type) {
                    case 5:
                        if(this.vmap == null) return d.vmap == null;
                        if(d.vmap == null) return false;
                        if(this.vmap.size() == 0 && d.vmap.size() == 0) return true;
                        return this.vmap == d.vmap; 
                    case 6:
                        if(this.vmap == null) return d.varray == null;
                        return false;
                }
            case 6:
                if(d == null) return this.varray == null;
                switch (d.type) {
                    case 6:
                        if(this.varray == null) return d.varray == null;
                        if(d.varray == null) return false;
                        if(this.varray.size() == 0 && d.varray.size() == 0) return true;
                        return this.varray == d.varray; 
                }
        }
        return false;
    }
private boolean compareTo ( Data d ) { if ( d != null && d . type < this . type ) return d . compareTo ( this ) ; switch ( this . type ) { case 1 : if ( d == null ) return ! this . vboolean ; return ( d . toBoolean ( ) == this . vboolean ) ; case 2 : if ( d == null ) return this . vint == 0 ; switch ( d . type ) { case 2 : return this . vint == d . vint ; case 3 : return d . vfloat == ( double ) this . vint ; case 4 : try { int id = Integer . parseInt ( d . vstring ) ; return this . vint == id ; } catch ( NumberFormatException ex ) { if ( "" . equals ( d . vstring ) ) return this . vint == 0 ; return false ; } case 5 : return this . vint == 0 && d . vmap == null ; case 6 : return this . vint == 0 && d . varray == null ; } case 3 : if ( d == null ) return this . vfloat == 0 ; switch ( d . type ) { case 3 : return this . vfloat == d . vfloat ; case 4 : Object nd = d . toNumber ( ) ; if ( nd instanceof Integer || nd instanceof Double ) return this . vfloat == ( Double ) nd ; return false ; case 5 : return this . vfloat == 0 && d . vmap == null ; case 6 : return this . vfloat == 0 && d . varray == null ; } case 4 : if ( d == null ) return "" . equals ( this . vstring ) ; switch ( d . type ) { case 4 : return this . vstring . equals ( d . vstring ) ; case 5 : return "" . equals ( this . vstring ) && d . vmap == null ; case 6 : return "" . equals ( this . vstring ) && d . varray == null ; } case 5 : if ( d == null ) return this . vmap == null ; switch ( d . type ) { case 5 : if ( this . vmap == null ) return d . vmap == null ; if ( d . vmap == null ) return false ; if ( this . vmap . size ( ) == 0 && d . vmap . size ( ) == 0 ) return true ; return this . vmap == d . vmap ; case 6 : if ( this . vmap == null ) return d . varray == null ; return false ; } case 6 : if ( d == null ) return this . varray == null ; switch ( d . type ) { case 6 : if ( this . varray == null ) return d . varray == null ; if ( d . varray == null ) return false ; if ( this . varray . size ( ) == 0 && d . varray . size ( ) == 0 ) return true ; return this . varray == d . varray ; } } return false ; }
Compare with another instance.
Compare with another instance .
//TODO: deep compare //TODO: deep compare