// Path: app/src/main/java/com/waynedgrant/cirrus/measures/WindDirection.java
// public class WindDirection {
//     private Integer compassDegrees;
//     private CardinalDirection cardinalDirection;
// 
//     public WindDirection(Integer degrees) {
//         this.compassDegrees = degrees;
//         this.cardinalDirection = CardinalDirection.values()[(int) (((degrees + 11) / 22.5) % 16)];
//     }
// 
//     public Integer getCompassDegrees() {
//         return compassDegrees;
//     }
// 
//     public CardinalDirection getCardinalDirection() {
//         return cardinalDirection;
//     }
// }
// 
// Path: app/src/main/java/com/waynedgrant/cirrus/units/WindDirectionUnit.java
// public enum WindDirectionUnit {
//     CARDINAL_DIRECTION("Cardinal Direction"),
//     COMPASS_DEGREES("Compass Degrees");
// 
//     private String description;
// 
//     WindDirectionUnit(String description) {
//         this.description = description;
//     }
// 
//     public String toString() {
//         return description;
//     }
// }


import java.util.Locale;
import static com.waynedgrant.cirrus.units.WindDirectionUnit.COMPASS_DEGREES;
import com.waynedgrant.cirrus.measures.WindDirection;
import com.waynedgrant.cirrus.units.WindDirectionUnit;
/* Copyright 2017 Wayne D Grant (www.waynedgrant.com)
   Licensed under the MIT License */

package com.waynedgrant.cirrus.presentation.formatters;




public class WindDirectionFormatter {
    private WindDirection windDirection;

    public WindDirectionFormatter(WindDirection windDirection) {
        this.windDirection = windDirection;
    }

    public String format(WindDirectionUnit unit) {
        String formatted;

        if (windDirection != null) {
            if (unit == COMPASS_DEGREES) {
                formatted = String.format(Locale.US, "%1d°", windDirection.getCompassDegrees());
            } else {
                formatted = String.format(Locale.US, "%1s", windDirection.getCardinalDirection().name());
            }
        } else {
            if (unit == WindDirectionUnit.COMPASS_DEGREES) {
                formatted = "---°";
// Path: app/src/main/java/com/waynedgrant/cirrus/measures/WindDirection.java
// public class WindDirection {
//     private Integer compassDegrees;
//     private CardinalDirection cardinalDirection;
// 
//     public WindDirection(Integer degrees) {
//         this.compassDegrees = degrees;
//         this.cardinalDirection = CardinalDirection.values()[(int) (((degrees + 11) / 22.5) % 16)];
//     }
// 
//     public Integer getCompassDegrees() {
//         return compassDegrees;
//     }
// 
//     public CardinalDirection getCardinalDirection() {
//         return cardinalDirection;
//     }
// }
// 
// Path: app/src/main/java/com/waynedgrant/cirrus/units/WindDirectionUnit.java
// public enum WindDirectionUnit {
//     CARDINAL_DIRECTION("Cardinal Direction"),
//     COMPASS_DEGREES("Compass Degrees");
// 
//     private String description;
// 
//     WindDirectionUnit(String description) {
//         this.description = description;
//     }
// 
//     public String toString() {
//         return description;
//     }
// }


// Path: app/src/main/java/com/waynedgrant/cirrus/presentation/formatters/WindDirectionFormatter.java
import java.util.Locale;
import static com.waynedgrant.cirrus.units.WindDirectionUnit.COMPASS_DEGREES;
import com.waynedgrant.cirrus.measures.WindDirection;
import com.waynedgrant.cirrus.units.WindDirectionUnit;

/* Copyright 2017 Wayne D Grant (www.waynedgrant.com)
   Licensed under the MIT License */

package com.waynedgrant.cirrus.presentation.formatters;




public class WindDirectionFormatter {
    private WindDirection windDirection;

    public WindDirectionFormatter(WindDirection windDirection) {
        this.windDirection = windDirection;
    }

    public String format(WindDirectionUnit unit) {
        String formatted;

        if (windDirection != null) {
            if (unit == COMPASS_DEGREES) {
                formatted = String.format(Locale.US, "%1d°", windDirection.getCompassDegrees());
            } else {
                formatted = String.format(Locale.US, "%1s", windDirection.getCardinalDirection().name());
            }
        } else {
            if (unit == WindDirectionUnit.COMPASS_DEGREES) {
                formatted = "---°";
            } else {