Skip to content

Commit

Permalink
Merge pull request #9 from jbarr21/jb/simplify-enum
Browse files Browse the repository at this point in the history
Remove boilerplate
  • Loading branch information
Jawnnypoo authored Aug 25, 2018
2 parents 78781fb + d3d8bc1 commit 3f92801
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 69 deletions.
4 changes: 2 additions & 2 deletions src/main/kotlin/com/commit451/resourcespoet/Plural.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ package com.commit451.resourcespoet
* Represents an Android Plural
* See <a https:></a>//developer.android.com/guide/topics/resources/string-resource.html#Plurals">https://developer.android.com/guide/topics/resources/string-resource.html#Plurals
*/
class Plural
data class Plural
/**
* Construct a new plural
* @param quantity the quantity
* @param value the value
*/
(var quantity: Quantity, var value: String) {
(val quantity: Quantity, val value: String) {

enum class Quantity {
zero,
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/com/commit451/resourcespoet/StyleItem.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ package com.commit451.resourcespoet
*
* <item name="android:windowBackground">@android:color/black</item>
*/
class StyleItem(var name: String, var value: String)
data class StyleItem(val name: String, val value: String)
81 changes: 15 additions & 66 deletions src/main/kotlin/com/commit451/resourcespoet/Type.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,72 +5,21 @@ package com.commit451.resourcespoet
*
* [Available Resources](https://developer.android.com/guide/topics/resources/available-resources.html)
*/
enum class Type {
enum class Type(private val xmlName: String) {

ATTR {
override fun toString(): String {
return "attr"
}
},
BOOL {
override fun toString(): String {
return "bool"
}
},
COLOR {
override fun toString(): String {
return "color"
}
},
DRAWABLE {
override fun toString(): String {
return "drawable"
}
},
DIMENSION {
override fun toString(): String {
return "dimen"
}
},
ID {
override fun toString(): String {
return "item"
}
},
INTEGER {
override fun toString(): String {
return "integer"
}
},
INTEGER_ARRAY {
override fun toString(): String {
return "integer-array"
}
},
PLURALS {
override fun toString(): String {
return "plurals"
}
},
STRING {
override fun toString(): String {
return "string"
}
},
STRING_ARRAY {
override fun toString(): String {
return "string-array"
}
},
STYLE {
override fun toString(): String {
return "style"
}
},
TYPED_ARRAY {
override fun toString(): String {
return "array"
}
}
ATTR("attr"),
BOOL("bool"),
COLOR("color"),
DRAWABLE("drawable"),
DIMENSION("dimen"),
ID("item"),
INTEGER("integer"),
INTEGER_ARRAY("integer-array"),
PLURALS("plurals"),
STRING("string"),
STRING_ARRAY("string-array"),
STYLE("style"),
TYPED_ARRAY("array");

override fun toString() = xmlName
}

0 comments on commit 3f92801

Please sign in to comment.