/*
 *  Licensed to Peter Karich under one or more contributor license
 *  agreements. See the NOTICE file distributed with this work for
 *  additional information regarding copyright ownership.
 *
 *  Peter Karich licenses this file to you under the Apache License,
 *  Version 2.0 (the "License"); you may not use this file except
 *  in compliance with the License. You may obtain a copy of the
 *  License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */
package com.graphhopper.util;

/**
 * @author Peter Karich
 */
public class InstructionAnnotation
{
    public final static InstructionAnnotation EMPTY = new InstructionAnnotation();
    private final boolean empty;
    private final int importance;
    private final String message;

    private InstructionAnnotation()
    {
        this.empty = true;
        this.importance = 0;
        this.message = "";
    }

    public InstructionAnnotation( int importance, String message )
    {
        this.empty = false;
        this.importance = importance;
        this.message = message;
    }

    public boolean isEmpty()
    {
        return empty;
    }

    public int getImportance()
    {
        return importance;
    }

    public String getMessage()
    {
        return message;
    }

    @Override
    public String toString()
    {
        return importance + ": " + getMessage();
    }

    @Override
    public int hashCode()
    {
        int hash = 3;
        hash = 83 * hash + this.importance;
        hash = 83 * hash + (this.message != null ? this.message.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals( Object obj )
    {
        if (obj == null)
            return false;
        if (getClass() != obj.getClass())
            return false;
        final InstructionAnnotation other = (InstructionAnnotation) obj;
        if (this.importance != other.importance)
            return false;
        if ((this.message == null) ? (other.message != null) : !this.message.equals(other.message))
            return false;
        return true;
    }
}

@@ -989,22 +989,16 @@
 private 
-final 
 boolean 
@@ -1016,22 +1016,16 @@
 private 
-final 
 int impo
@@ -1044,22 +1044,16 @@
 private 
-final 
 String m
@@ -1115,81 +1115,18 @@
     
-this.empty = true;%0A        this.importance = 0;%0A        this.message = %22%22
+setEmpty()
 ;%0A  
@@ -1195,32 +1195,145 @@
 message )%0A    %7B%0A
+        if (message.isEmpty() && importance == 0)%0A        %7B%0A            setEmpty();%0A        %7D else%0A        %7B%0A    
         this.emp
@@ -1348,24 +1348,28 @@
 se;%0A        
+   
+ 
 this.importa
@@ -1390,24 +1390,28 @@
 ce;%0A        
+    
 this.message
@@ -1414,32 +1414,166 @@
 sage = message;%0A
+        %7D%0A    %7D%0A%0A    private void setEmpty()%0A    %7B%0A        this.empty = true;%0A        this.importance = 0;%0A        this.message = %22%22;%0A
     %7D%0A%0A    publi

empty annotation if message is empty