You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

NestPropertiesNode.java 1.1KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. package com.vaadin.sass.tree;
  2. import java.util.ArrayList;
  3. import java.util.Collection;
  4. import java.util.List;
  5. public class NestPropertiesNode extends Node {
  6. private static final long serialVersionUID = 3671253315690598308L;
  7. public NestPropertiesNode(String name) {
  8. super();
  9. this.name = name;
  10. }
  11. private String name;
  12. public String getName() {
  13. return name;
  14. }
  15. public void setName(String name) {
  16. this.name = name;
  17. }
  18. public Collection<RuleNode> unNesting() {
  19. List<RuleNode> result = new ArrayList<RuleNode>();
  20. for (Node child : children) {
  21. result.add(createNewRuleNodeFromChild((RuleNode) child));
  22. }
  23. return result;
  24. }
  25. public RuleNode createNewRuleNodeFromChild(RuleNode child) {
  26. StringBuilder builder = new StringBuilder(name);
  27. builder.append("-").append(child.getVariable());
  28. RuleNode newRuleNode = new RuleNode(builder.toString(),
  29. child.getValue(), child.isImportant(), null);
  30. return newRuleNode;
  31. }
  32. }