Skip to content

Commit

Permalink
Code cleanup: "redundant" public keyword removed
Browse files Browse the repository at this point in the history
  • Loading branch information
Tapac committed Apr 8, 2016
1 parent 2b5bd3e commit 20d2478
Show file tree
Hide file tree
Showing 52 changed files with 444 additions and 442 deletions.
4 changes: 2 additions & 2 deletions samples/KaraDemo/src/kara/demo/Application.kt
@@ -1,6 +1,6 @@
package kara.demo

import kara.*
import kara.ApplicationConfig


public class Application(config: ApplicationConfig) : kara.Application(config)
class Application(config: ApplicationConfig) : kara.Application(config)
6 changes: 3 additions & 3 deletions samples/KaraDemo/src/kara/demo/models/Post.kt
@@ -1,11 +1,11 @@
package kara.demo.models

import java.util.Date
import java.util.*

/**
*/
public class Post(var date : Date, var title : String) {
class Post(var date : Date, var title : String) {

public var body : String = ""
var body : String = ""

}
2 changes: 1 addition & 1 deletion samples/KaraDemo/src/kara/demo/styles/StyleClasses.kt
Expand Up @@ -3,7 +3,7 @@ package kara.demo.styles
import kara.*
import kotlinx.html.*

public enum class StyleClasses : StyleClass {
enum class StyleClasses : StyleClass {
fields, cLabel, top,
date, title, body
}
22 changes: 11 additions & 11 deletions src/ConfigReader/src/kara/config/Config.kt
Expand Up @@ -9,21 +9,21 @@ import javax.naming.Context
import javax.naming.InitialContext
import javax.naming.NamingException

public open class Config() {
public class MissingException(desc: String) : RuntimeException(desc)
open class Config() {
class MissingException(desc: String) : RuntimeException(desc)

val data = LinkedHashMap<String, String>()
val cache = ConcurrentHashMap<String, String?>()
protected val data = LinkedHashMap<String, String>()
protected val cache = ConcurrentHashMap<String, String?>()

/**
* Gets the value for the given key.
* Will raise an exception if the value isn't present. Try calling contains(key) first if you're unsure.
*/
operator public fun get(name: String): String {
operator fun get(name: String): String {
return tryGet(name) ?: throw MissingException("Could not find config value for key $name")
}

public fun tryGet(name: String): String? {
fun tryGet(name: String): String? {
return lookupCache(name) {
lookupJNDI(name) ?: data[name]
}
Expand All @@ -40,17 +40,17 @@ public open class Config() {
}

/** Sets a value for the given key. */
operator public fun set(name: String, value: String) {
operator fun set(name: String, value: String) {
data[name] = value
}

/** Returns true if the config contains a value for the given key. */
public fun contains(name: String): Boolean {
fun contains(name: String): Boolean {
return data.containsKey(name) || lookupJNDI(name) != null
}

/** Prints the entire config to a nicely formatted string. */
public override fun toString(): String {
override fun toString(): String {
val builder = StringBuilder()
for (name in data.keys) {
builder.append("$name: ${data[name]}\n")
Expand All @@ -70,10 +70,10 @@ public open class Config() {
}
}

public companion object {
companion object {
val logger = Logger.getLogger(Config::class.java)!!

public fun readConfig(config: Config, path: String, classloader: ClassLoader, baseFile: File? = null) {
fun readConfig(config: Config, path: String, classloader: ClassLoader, baseFile: File? = null) {
fun eval(name: String): String {
return config.tryGet(name) ?: System.getProperty(name) ?: System.getenv(name) ?: error("$name is not defined")
}
Expand Down
2 changes: 1 addition & 1 deletion src/HTMLBuilder/src/kotlinx/html/AttributeFilters.kt
@@ -1,6 +1,6 @@
package kotlinx.html

public interface AttFilter {
interface AttFilter {
fun toExternalForm(): String
}

Expand Down
26 changes: 13 additions & 13 deletions src/HTMLBuilder/src/kotlinx/html/AttributeTypes.kt
Expand Up @@ -2,7 +2,7 @@ package kotlinx.html

import kotlin.reflect.KProperty

public abstract class Attribute<T>(val name: String) {
abstract class Attribute<T>(val name: String) {
operator fun getValue(tag: HtmlTag, property: KProperty<*>): T {
return decode(tag[name]);
}
Expand All @@ -14,7 +14,7 @@ public abstract class Attribute<T>(val name: String) {
abstract fun decode(s: String?): T
}

public open class StringAttribute(name: String) : Attribute<String>(name) {
open class StringAttribute(name: String) : Attribute<String>(name) {
override fun encode(t: String): String? {
return t // TODO: it actually might need HTML esaping
}
Expand All @@ -24,12 +24,12 @@ public open class StringAttribute(name: String) : Attribute<String>(name) {
}
}

public class TextAttribute(name: String) : StringAttribute(name)
public class RegexpAttribute(name: String) : StringAttribute(name)
public class IdAttribute(name: String) : StringAttribute(name)
public class MimeAttribute(name: String) : StringAttribute(name)
class TextAttribute(name: String) : StringAttribute(name)
class RegexpAttribute(name: String) : StringAttribute(name)
class IdAttribute(name: String) : StringAttribute(name)
class MimeAttribute(name: String) : StringAttribute(name)

public class IntAttribute(name: String) : Attribute<Int>(name) {
class IntAttribute(name: String) : Attribute<Int>(name) {
override fun encode(t: Int): String? {
return t.toString()
}
Expand All @@ -39,7 +39,7 @@ public class IntAttribute(name: String) : Attribute<Int>(name) {
}
}

public class BooleanAttribute(name: String, val trueValue: String = "true", val falseValue: String = "false") : Attribute<Boolean>(name) {
class BooleanAttribute(name: String, val trueValue: String = "true", val falseValue: String = "false") : Attribute<Boolean>(name) {
override fun encode(t: Boolean): String? {
return if (t) trueValue else falseValue
}
Expand All @@ -53,7 +53,7 @@ public class BooleanAttribute(name: String, val trueValue: String = "true", val
}
}

public class TickerAttribute(name: String) : Attribute<Boolean>(name) {
class TickerAttribute(name: String) : Attribute<Boolean>(name) {
override fun encode(t: Boolean): String? {
return null
}
Expand All @@ -71,7 +71,7 @@ public class TickerAttribute(name: String) : Attribute<Boolean>(name) {
}
}

public class LinkAttribute(name: String) : Attribute<Link>(name) {
class LinkAttribute(name: String) : Attribute<Link>(name) {
override fun encode(t: Link): String? {
return t.href()
}
Expand All @@ -81,11 +81,11 @@ public class LinkAttribute(name: String) : Attribute<Link>(name) {
}
}

public interface StringEnum<T : Enum<T>> {
interface StringEnum<T : Enum<T>> {
val value: String
}

public class EnumAttribute<T>(name: String, val klass: Class<T>) : Attribute<T>(name)
class EnumAttribute<T>(name: String, val klass: Class<T>) : Attribute<T>(name)
where T : StringEnum<T>, T : Enum<T>
{
override fun encode(t: T): String? {
Expand All @@ -101,7 +101,7 @@ public class EnumAttribute<T>(name: String, val klass: Class<T>) : Attribute<T>(
}
}

public class MimeTypesAttribute(name: String) : Attribute<List<String>>(name) {
class MimeTypesAttribute(name: String) : Attribute<List<String>>(name) {

override fun encode(t: List<String>): String? {
return t.joinToString(",")
Expand Down
4 changes: 2 additions & 2 deletions src/HTMLBuilder/src/kotlinx/html/Color.kt
Expand Up @@ -24,12 +24,12 @@ class Color(var red: Double, var green: Double, var blue: Double, var alpha: Dou
companion object {

/** Creates a color from integer RGBA values between 0 and 255. */
public fun fromRgb(red: Int, green: Int, blue: Int, alpha: Int = 255): Color {
fun fromRgb(red: Int, green: Int, blue: Int, alpha: Int = 255): Color {
return Color(red.toDouble() / 255, green.toDouble() / 255.0, blue.toDouble() / 255.0, alpha.toDouble() / 255.0)
}

/** Makes a color from a hex string (hash included). */
public fun fromHex(s : String) : Color {
fun fromHex(s : String) : Color {
// TODO 4/8-digit are actually not supported by CSS spec, make framework parse rgb/rgba() format instead

if (s.length == 4 && s[0] == '#') {
Expand Down
36 changes: 18 additions & 18 deletions src/HTMLBuilder/src/kotlinx/html/CssDSL.kt
Expand Up @@ -16,15 +16,15 @@ object EmptyTrait : SelectorTrait {
}
}

public interface StyleClass : SelectorTrait, Selector {
interface StyleClass : SelectorTrait, Selector {
val name: String

override fun toExternalForm(): String {
return ".${name}"
}
}

public class SimpleClassStyle(override val name : String) : StyleClass {
class SimpleClassStyle(override val name : String) : StyleClass {
}

class CompositeStyleClass(val a: StyleClass, val b: StyleClass) : StyleClass {
Expand All @@ -35,14 +35,14 @@ class CompositeStyleClass(val a: StyleClass, val b: StyleClass) : StyleClass {
}
}

operator public fun StyleClass?.plus(another: StyleClass?): StyleClass? = when {
operator fun StyleClass?.plus(another: StyleClass?): StyleClass? = when {
this == null && another == null -> null
this == null -> another
another == null -> this
else -> CompositeStyleClass(this, another)
}

public enum class PseudoClass : StyleClass {
enum class PseudoClass : StyleClass {
root, firstChild, lastChild, firstOfType, lastOfType, onlyChild, onlyOfType,
empty, link, visited, active, focus, hover, target, enabled, disabled, checked;

Expand All @@ -58,7 +58,7 @@ open class CssElement() {
val children = arrayListOf<StyledElement>()
val attributes = HashMap<String, Any>()

public inner class IdSelector(val name: String) : SelectorTrait, Selector {
inner class IdSelector(val name: String) : SelectorTrait, Selector {
operator fun invoke(body: StyledElement.() -> Unit) {
any.invoke(this, body = body)
}
Expand All @@ -68,7 +68,7 @@ open class CssElement() {
}
}

public inner open class TagSelector(val name: String) : Selector {
inner open class TagSelector(val name: String) : Selector {
fun id(name: String): Selector = invoke(IdSelector(name))
fun id(name: String, body: StyledElement.() -> Unit) = id(IdSelector(name), body)
fun id(id: IdSelector, body: StyledElement.() -> Unit) = invoke(id, body = body)
Expand Down Expand Up @@ -138,40 +138,40 @@ open class CssElement() {
val dd: TagSelector get() = TagSelector("dd")


public fun id(name: String, body: StyledElement.() -> Unit) {
fun id(name: String, body: StyledElement.() -> Unit) {
any.id(name, body)
}

public fun id(name: String): IdSelector = IdSelector(name)
fun id(name: String): IdSelector = IdSelector(name)

fun c(klass: StyleClass, body: StyledElement.() -> Unit) {
any.invoke(klass, body = body)
}

public fun att(name: String): Attribute = Attribute(name, kotlinx.html.HasAttribute(name))
fun att(name: String): Attribute = Attribute(name, kotlinx.html.HasAttribute(name))

public class Attribute internal constructor(val name: String, val filter: kotlinx.html.AttFilter) : SelectorTrait {
public infix fun startsWith(value: String): Attribute {
class Attribute internal constructor(val name: String, val filter: kotlinx.html.AttFilter) : SelectorTrait {
infix fun startsWith(value: String): Attribute {
return Attribute(name, kotlinx.html.StartsWith(value))
}

public infix fun equalTo(value: String): Attribute {
infix fun equalTo(value: String): Attribute {
return Attribute(name, kotlinx.html.Equals(value))
}

public infix fun endsWith(value: String): Attribute {
infix fun endsWith(value: String): Attribute {
return Attribute(name, kotlinx.html.EndsWith(value))
}

public infix fun contains(value: String): Attribute {
infix fun contains(value: String): Attribute {
return Attribute(name, kotlinx.html.Contains(value, kotlinx.html.AttributeValueTokenizer.Substring))
}

public infix fun containsInHypen(value: String): Attribute {
infix fun containsInHypen(value: String): Attribute {
return Attribute(name, kotlinx.html.Contains(value, kotlinx.html.AttributeValueTokenizer.Hypen))
}

public infix fun containsInSpaces(value: String): Attribute {
infix fun containsInSpaces(value: String): Attribute {
return Attribute(name, kotlinx.html.Contains(value, kotlinx.html.AttributeValueTokenizer.Spaces))
}

Expand Down Expand Up @@ -201,11 +201,11 @@ open class CssElement() {
}
}

public fun forAny(vararg selectors: Selector, body: StyledElement.() -> Unit) {
fun forAny(vararg selectors: Selector, body: StyledElement.() -> Unit) {
s(UnionSelector(selectors).toExternalForm(), body)
}

public fun forAny(vararg selectors: Selector): UnionSelector {
fun forAny(vararg selectors: Selector): UnionSelector {
return UnionSelector(selectors)
}

Expand Down
4 changes: 2 additions & 2 deletions src/HTMLBuilder/src/kotlinx/html/Dimensions.kt
Expand Up @@ -39,7 +39,7 @@ class LinearDimension(var value: Double, var units: LinearUnits) {
}

/** Use this instance to specify the auto keyword for linear dimensions. */
public val auto: LinearDimension = LinearDimension(0.0, LinearUnits.auto)
val auto: LinearDimension = LinearDimension(0.0, LinearUnits.auto)

/** Returns true if the given string represents a valid linear dimension */
fun isLinearDimension(s: String): Boolean {
Expand All @@ -56,7 +56,7 @@ val Int.em: LinearDimension get() = LinearDimension(this.toDouble(), LinearUnits
val Double.px: LinearDimension get() = LinearDimension(this, LinearUnits._px)

/** Extenion property to convert an int to a LinearDimension with units px. */
public val Int.px: LinearDimension get() = LinearDimension(this.toDouble(), LinearUnits._px)
val Int.px: LinearDimension get() = LinearDimension(this.toDouble(), LinearUnits._px)

/** Extenion property to convert a double to a LinearDimension with units percent. */
val Double.percent: LinearDimension get() = LinearDimension(this, LinearUnits._percent)
Expand Down
2 changes: 1 addition & 1 deletion src/HTMLBuilder/src/kotlinx/html/EncodingType.kt
@@ -1,6 +1,6 @@
package kotlinx.html

public enum class EncodingType(override val value: String) : StringEnum<EncodingType> {
enum class EncodingType(override val value: String) : StringEnum<EncodingType> {
urlencoded("application/x-www-form-urlencoded"),
multipart("multipart/form-data"),
plain("text/plain")
Expand Down
8 changes: 4 additions & 4 deletions src/HTMLBuilder/src/kotlinx/html/Events.kt
@@ -1,6 +1,6 @@
package kotlinx.html

public var A.onClick: String by StringAttribute("onclick")
public var INPUT.onChange: String by StringAttribute("onchange")
public var SELECT.onChange: String by StringAttribute("onchange")
public var INPUT.onKeyUp: String by StringAttribute("onkeyup")
var A.onClick: String by StringAttribute("onclick")
var INPUT.onChange: String by StringAttribute("onchange")
var SELECT.onChange: String by StringAttribute("onchange")
var INPUT.onKeyUp: String by StringAttribute("onkeyup")
2 changes: 1 addition & 1 deletion src/HTMLBuilder/src/kotlinx/html/FormMethod.kt
@@ -1,6 +1,6 @@
package kotlinx.html

public enum class FormMethod() : StringEnum<FormMethod> {
enum class FormMethod() : StringEnum<FormMethod> {
get,
post,
put,
Expand Down

0 comments on commit 20d2478

Please sign in to comment.