Package com.github.sommeri.less4j.core.compiler.selectors

Source Code of com.github.sommeri.less4j.core.compiler.selectors.NthComparatorForExtend

package com.github.sommeri.less4j.core.compiler.selectors;

import com.github.sommeri.less4j.core.ast.Nth;
import com.github.sommeri.less4j.core.ast.NumberExpression;
import com.github.sommeri.less4j.core.compiler.expressions.FormalisticExpressionComparator;
import com.github.sommeri.less4j.core.problems.BugHappened;

public class NthComparatorForExtend {
 
  private FormalisticExpressionComparator expressionComparator = new FormalisticExpressionComparator();

  public boolean equals(Nth nth1, Nth nth2) {
    if (nth1.getForm() != nth2.getForm())
      return false;

    switch (nth1.getForm()) {
    case EVEN:
    case ODD:
      return true;

    case STANDARD:
      return equals(nth1.getRepeater(), nth2.getRepeater()) && equals(nth1.getMod(), nth2.getMod());
     
    }

    throw new BugHappened("Should not happen. " + nth1 + " vs " + nth2, nth1);
  }

  private boolean equals(NumberExpression v1, NumberExpression v2) {
    if (v1 == null || v2 == null)
      return (v1 == null && v2 == null);

    return expressionComparator.equal(v1, v2);
  }
}
TOP

Related Classes of com.github.sommeri.less4j.core.compiler.selectors.NthComparatorForExtend

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.