File indexing completed on 2024-12-15 04:19:54

0001 package mso.generator.utils;
0002 
0003 import org.eclipse.jdt.annotation.Nullable;
0004 import org.w3c.dom.Element;
0005 
0006 public class Limitation {
0007     public final String name;
0008     @Nullable
0009     public final String expression;
0010     @Nullable
0011     public final String value;
0012 
0013     Limitation(Element e) {
0014         name = e.getAttribute("name");
0015         if (e.hasAttribute("expression")) {
0016             expression = e.getAttribute("expression");
0017             value = null;
0018         } else {
0019             expression = null;
0020             value = e.getAttribute("value");
0021         }
0022     }
0023 
0024     public boolean equals(@Nullable Object o) {
0025         if (!(o instanceof Limitation))
0026             return false;
0027         Limitation l = (Limitation) o;
0028         if (!l.name.equals(name))
0029             return false;
0030         final String lexpression = l.expression;
0031         if (expression != null) {
0032             if (lexpression == null || !lexpression.equals(expression))
0033                 return false;
0034         }
0035         // value is not null
0036         final String lvalue = l.value;
0037         if (lvalue == null || !lvalue.equals(value))
0038             return false;
0039         return true;
0040     }
0041 }