package eu.yaga;

import java.util.logging.Logger;

/**
 * Analyzes if the moisture has fallen below the border
 * or recovered after being fallen below that border
 */
public class MoistureAnalyzer {
    private static final Logger LOGGER = Logger.getLogger(MoistureAnalyzer.class.getName());

    private int lastMoisture = 0;
    private static int LOWER_BORDER;
    private static String OWNER;

    public MoistureAnalyzer(int border, String owner) {
        LOWER_BORDER = border;
        OWNER = owner;
    }

    /**
     * Analyze the current moisture value and return Tweet
     *
     * @param moisture current moisture value
     * @return message or null, if nothing changed
     */
    public String analyze(int moisture) {
        LOGGER.info("Analyzing moisture (" + moisture + ") / last moisture: " + lastMoisture);

        int lastMoistureTmp = lastMoisture;
        lastMoisture = moisture;

        if (moisture <= LOWER_BORDER && lastMoistureTmp > LOWER_BORDER) {
            LOGGER.info("Moisture has fallen below border (" + LOWER_BORDER + ").");
            return TweetMessageGenerator.createPourTweet(OWNER, moisture);
        }

        if (moisture > LOWER_BORDER && lastMoistureTmp <= LOWER_BORDER) {
            LOGGER.info("Moisture recovered (>" + LOWER_BORDER + ")");
            return TweetMessageGenerator.createPourTweet(OWNER, moisture);
        }

        return null;
    }
}

@@ -905,16 +905,56 @@
 sture;%0A%0A
+        if (lastMoistureTmp != 0) %7B%0A    
         
@@ -1023,32 +1023,36 @@
 ) %7B%0A            
+   
+ 
 LOGGER.info(%22Moi
@@ -1112,32 +1112,36 @@
 %22);%0A            
+    
 return TweetMess
@@ -1187,32 +1187,36 @@
 sture);%0A        
+    
 %7D%0A%0A        if (m
@@ -1202,32 +1202,36 @@
      %7D%0A%0A        
+  
+  
 if (moisture %3E L
@@ -1272,32 +1272,36 @@
 LOWER_BORDER) %7B%0A
+    
             LOGG
@@ -1359,32 +1359,36 @@
 %22);%0A            
+    
 return TweetMess
@@ -1398,36 +1398,40 @@
 Generator.create
-Pour
+Recovery
 Tweet(OWNER, moi
@@ -1430,32 +1430,46 @@
 NER, moisture);%0A
+            %7D%0A
         %7D%0A%0A     

fix tweet generation