package org.fakekoji.model;

import java.util.Map;
import java.util.Objects;

public class TaskVariantCategory {

    private final String id;
    private final String label;
    private final Usage type;
    private final int order;
    private final Map<String, TaskVariant> variants;

    public TaskVariantCategory() {
        id = null;
        label = null;
        type = null;
        order = -1;
        variants = null;
    }

    public TaskVariantCategory(
            String id,
            String label,
            Usage type,
            int order,
            Map<String, TaskVariant> variants
    ) {
        this.id = id;
        this.label = label;
        this.type = type;
        this.order = order;
        this.variants = variants;
    }

    public String getId() {
        return id;
    }

    public String getLabel() {
        return label;
    }

    public Usage getType() {
        return type;
    }

    public int getOrder() {
        return order;
    }

    public Map<String, TaskVariant> getVariants() {
        return variants;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof TaskVariantCategory)) return false;
        TaskVariantCategory category = (TaskVariantCategory) o;
        return order == category.order &&
                Objects.equals(id, category.id) &&
                Objects.equals(label, category.label) &&
                type == category.type &&
                Objects.equals(variants, category.variants);
    }

    @Override
    public int hashCode() {
        return Objects.hash(id, label, type, order, variants);
    }

    @Override
    public String toString() {
        return "TaskVariantCategory{" +
                "id='" + id + '\'' +
                ", label='" + label + '\'' +
                ", type=" + type +
                ", order=" + order +
                ", variants=" + variants +
                '}';
    }

    public enum Usage {
        BUILD("BUILD"),
        TEST("TEST");

        private final String value;

        Usage(String value) {
            this.value = value;
        }

        public String getValue() {
            return value;
        }
    }
}

@@ -103,16 +103,59 @@
 Category
+ implements Comparable%3CTaskVariantCategory%3E
  %7B%0A%0A    
@@ -2000,32 +2000,432 @@
     '%7D';%0A    %7D%0A%0A
+    @Override%0A    public int compareTo(TaskVariantCategory taskVariantCategory) %7B%0A        if (type == null %7C%7C taskVariantCategory == null %7C%7C taskVariantCategory.type == null) %7B%0A            return 0;%0A        %7D%0A        if (type.order == taskVariantCategory.type.order) %7B%0A            return order - taskVariantCategory.order;%0A        %7D%0A        return type.order - taskVariantCategory.type.order;%0A    %7D%0A%0A
     public enum 
@@ -2453,16 +2453,19 @@
 (%22BUILD%22
+, 0
 ),%0A     
@@ -2478,16 +2478,19 @@
 T(%22TEST%22
+, 1
 );%0A%0A    
@@ -2520,16 +2520,49 @@
 g value;
+%0A        private final int order;
 %0A%0A      
@@ -2581,16 +2581,27 @@
 ng value
+, int order
 ) %7B%0A    
@@ -2620,32 +2620,64 @@
 .value = value;%0A
+            this.order = order;%0A
         %7D%0A%0A     
@@ -2737,21 +2737,90 @@
 e;%0A        %7D
+%0A%0A        public int getOrder() %7B%0A            return order;%0A        %7D
 %0A    %7D%0A%7D%0A

Add compareTo method in TaskVariantCategory