diff options
author | Noel Grandin <noel@peralex.com> | 2014-11-11 15:32:10 +0200 |
---|---|---|
committer | Noel Grandin <noelgrandin@gmail.com> | 2014-11-12 08:01:55 +0000 |
commit | 36ff1527c9cb20542d3097d123d221c40a356795 (patch) | |
tree | 52590ce642803a862bc331b3eae2e2b100b8e85f /javaunohelper | |
parent | 1eb31467a5af90fe41dc646dd716bdb7d3e5db45 (diff) |
java: reduce excessive code indentation levels
by using early return in some methods
Change-Id: I3611c8c89b3a94ef7e1772d178acf065fd7fcdc7
Reviewed-on: https://gerrit.libreoffice.org/12374
Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
Tested-by: Noel Grandin <noelgrandin@gmail.com>
Diffstat (limited to 'javaunohelper')
-rw-r--r-- | javaunohelper/com/sun/star/lib/uno/helper/PropertySetMixin.java | 185 |
1 files changed, 93 insertions, 92 deletions
diff --git a/javaunohelper/com/sun/star/lib/uno/helper/PropertySetMixin.java b/javaunohelper/com/sun/star/lib/uno/helper/PropertySetMixin.java index f3d9a8e907b2..7e2af48e1e56 100644 --- a/javaunohelper/com/sun/star/lib/uno/helper/PropertySetMixin.java +++ b/javaunohelper/com/sun/star/lib/uno/helper/PropertySetMixin.java @@ -563,106 +563,107 @@ public final class PropertySetMixin { { XInterfaceTypeDescription2 ifc = UnoRuntime.queryInterface( XInterfaceTypeDescription2.class, resolveTypedefs(type)); - if (seen.add(ifc.getName())) { - XTypeDescription[] bases = ifc.getBaseTypes(); - for (int i = 0; i < bases.length; ++i) { - initProperties(bases[i], map, handleNames, seen); - } - XInterfaceMemberTypeDescription[] members = ifc.getMembers(); - for (int i = 0; i < members.length; ++i) { - if (members[i].getTypeClass() == TypeClass.INTERFACE_ATTRIBUTE) - { - XInterfaceAttributeTypeDescription2 attr = - UnoRuntime.queryInterface( - XInterfaceAttributeTypeDescription2.class, - members[i]); - short attrAttribs = 0; - if (attr.isBound()) { - attrAttribs |= PropertyAttribute.BOUND; + if (!seen.add(ifc.getName())) { + return; + } + XTypeDescription[] bases = ifc.getBaseTypes(); + for (int i = 0; i < bases.length; ++i) { + initProperties(bases[i], map, handleNames, seen); + } + XInterfaceMemberTypeDescription[] members = ifc.getMembers(); + for (int i = 0; i < members.length; ++i) { + if (members[i].getTypeClass() == TypeClass.INTERFACE_ATTRIBUTE) + { + XInterfaceAttributeTypeDescription2 attr = + UnoRuntime.queryInterface( + XInterfaceAttributeTypeDescription2.class, + members[i]); + short attrAttribs = 0; + if (attr.isBound()) { + attrAttribs |= PropertyAttribute.BOUND; + } + boolean setUnknown = false; + if (attr.isReadOnly()) { + attrAttribs |= PropertyAttribute.READONLY; + setUnknown = true; + } + XCompoundTypeDescription[] excs = attr.getGetExceptions(); + boolean getUnknown = false; + //XXX Special interpretation of getter/setter exceptions + // only works if the specified exceptions are of the exact + // type, not of a supertype: + for (int j = 0; j < excs.length; ++j) { + if (excs[j].getName().equals( + "com.sun.star.beans.UnknownPropertyException")) + { + getUnknown = true; + break; } - boolean setUnknown = false; - if (attr.isReadOnly()) { - attrAttribs |= PropertyAttribute.READONLY; + } + excs = attr.getSetExceptions(); + for (int j = 0; j < excs.length; ++j) { + if (excs[j].getName().equals( + "com.sun.star.beans.UnknownPropertyException")) + { setUnknown = true; + } else if (excs[j].getName().equals( + "com.sun.star.beans." + + "PropertyVetoException")) + { + attrAttribs |= PropertyAttribute.CONSTRAINED; } - XCompoundTypeDescription[] excs = attr.getGetExceptions(); - boolean getUnknown = false; - //XXX Special interpretation of getter/setter exceptions - // only works if the specified exceptions are of the exact - // type, not of a supertype: - for (int j = 0; j < excs.length; ++j) { - if (excs[j].getName().equals( - "com.sun.star.beans.UnknownPropertyException")) - { - getUnknown = true; - break; - } - } - excs = attr.getSetExceptions(); - for (int j = 0; j < excs.length; ++j) { - if (excs[j].getName().equals( - "com.sun.star.beans.UnknownPropertyException")) - { - setUnknown = true; - } else if (excs[j].getName().equals( - "com.sun.star.beans." - + "PropertyVetoException")) - { - attrAttribs |= PropertyAttribute.CONSTRAINED; - } - } - if (getUnknown && setUnknown) { - attrAttribs |= PropertyAttribute.OPTIONAL; + } + if (getUnknown && setUnknown) { + attrAttribs |= PropertyAttribute.OPTIONAL; + } + XTypeDescription t = attr.getType(); + for (;;) { + t = resolveTypedefs(t); + short n; + if (t.getName().startsWith( + "com.sun.star.beans.Ambiguous<")) + { + n = PropertyAttribute.MAYBEAMBIGUOUS; + } else if (t.getName().startsWith( + "com.sun.star.beans.Defaulted<")) + { + n = PropertyAttribute.MAYBEDEFAULT; + } else if (t.getName().startsWith( + "com.sun.star.beans.Optional<")) + { + n = PropertyAttribute.MAYBEVOID; + } else { + break; } - XTypeDescription t = attr.getType(); - for (;;) { - t = resolveTypedefs(t); - short n; - if (t.getName().startsWith( - "com.sun.star.beans.Ambiguous<")) - { - n = PropertyAttribute.MAYBEAMBIGUOUS; - } else if (t.getName().startsWith( - "com.sun.star.beans.Defaulted<")) - { - n = PropertyAttribute.MAYBEDEFAULT; - } else if (t.getName().startsWith( - "com.sun.star.beans.Optional<")) - { - n = PropertyAttribute.MAYBEVOID; - } else { + attrAttribs |= n; + t = (UnoRuntime.queryInterface( + XStructTypeDescription.class, t)). + getTypeArguments()[0]; + } + String name = members[i].getMemberName(); + boolean present = true; + if (absentOptional != null) { + for (int j = 0; j < absentOptional.length; ++j) { + if (name.equals(absentOptional[j])) { + present = false; break; } - attrAttribs |= n; - t = (UnoRuntime.queryInterface( - XStructTypeDescription.class, t)). - getTypeArguments()[0]; - } - String name = members[i].getMemberName(); - boolean present = true; - if (absentOptional != null) { - for (int j = 0; j < absentOptional.length; ++j) { - if (name.equals(absentOptional[j])) { - present = false; - break; - } - } } - if (map.put( - name, - new PropertyData( - new Property( - name, handleNames.size(), - new Type(t.getName(), t.getTypeClass()), - attrAttribs), - present)) - != null) - { - throw new RuntimeException( - "inconsistent UNO type registry"); - } - handleNames.add(name); } + if (map.put( + name, + new PropertyData( + new Property( + name, handleNames.size(), + new Type(t.getName(), t.getTypeClass()), + attrAttribs), + present)) + != null) + { + throw new RuntimeException( + "inconsistent UNO type registry"); + } + handleNames.add(name); } } } |