Skip to content

Commit

Permalink
Replace use of var by val
Browse files Browse the repository at this point in the history
  • Loading branch information
julianmendez committed Sep 1, 2018
1 parent d990545 commit 802c22d
Show file tree
Hide file tree
Showing 28 changed files with 233 additions and 273 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,11 @@ class CompositeTypeImpl extends CompositeType {
}

override def equals(obj: Any): Boolean = {
var result: Boolean = false
obj match {
val result = obj match {
case other: CompositeType =>
result = getFields.equals(other.getFields)
if (result) {
val fields: Seq[String] = getFields
result = result && fields.forall(field => getFieldType(field).equals(other.getFieldType(field)))
}
case _ => result = false
getFields.equals(other.getFields) &&
getFields.forall(field => getFieldType(field).equals(other.getFieldType(field)))
case _ => false
}
result
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,7 @@ class DecimalValue(number: BigDecimal) extends PrimitiveTypeValue {
}

override def renderAsList(): Seq[String] = {
val list = new mutable.ArrayBuffer[String]()
list += render()
val result = list.toList
result
List(render())
}

override def compareTo(other: PrimitiveTypeValue): Int = {
Expand All @@ -47,10 +44,9 @@ class DecimalValue(number: BigDecimal) extends PrimitiveTypeValue {
}

override def equals(obj: Any): Boolean = {
var result: Boolean = false
obj match {
case other: DecimalValue => result = this.number.equals(other.getValue)
case _ => result = false
val result = obj match {
case other: DecimalValue => this.number.equals(other.getValue)
case _ => false
}
result
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@

package de.tudresden.inf.lat.tabulas.datatype

import scala.collection.mutable

/** This models a empty value.
*
*/
Expand All @@ -23,7 +21,7 @@ class EmptyValue extends PrimitiveTypeValue {
}

override def renderAsList(): Seq[String] = {
new mutable.ArrayBuffer[String]().toList
List()
}

override def compareTo(other: PrimitiveTypeValue): Int = {
Expand All @@ -35,10 +33,9 @@ class EmptyValue extends PrimitiveTypeValue {
}

override def equals(obj: Any): Boolean = {
var result: Boolean = false
obj match {
case other: EmptyValue => result = true
case _ => result = false
val result = obj match {
case other: EmptyValue => true
case _ => false
}
result
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,9 @@ class IntegerType extends PrimitiveType {
}

override def equals(obj: Any): Boolean = {
var result = false
obj match {
case other: IntegerType => result = true
case _ => result = false
val result = obj match {
case other: IntegerType => true
case _ => false
}
result
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,7 @@ class IntegerValue(number: BigInteger) extends PrimitiveTypeValue {
}

override def renderAsList(): Seq[String] = {
val list = new mutable.ArrayBuffer[String]()
list += render()
val result: Seq[String] = list.toList
result
List(render())
}

override def compareTo(other: PrimitiveTypeValue): Int = {
Expand All @@ -47,10 +44,9 @@ class IntegerValue(number: BigInteger) extends PrimitiveTypeValue {
}

override def equals(obj: Any): Boolean = {
var result: Boolean = false
obj match {
case other: IntegerValue => result = this.number.equals(other.getValue)
case _ => result = false
val result = obj match {
case other: IntegerValue => this.number.equals(other.getValue)
case _ => false
}
result
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,10 @@ class ParameterizedListType extends PrimitiveType {
}

override def equals(obj: Any): Boolean = {
var result: Boolean = false
obj match {
val result = obj match {
case other: ParameterizedListType =>
result = this._parameter.equals(other._parameter)
case _ => result = false
this._parameter.equals(other._parameter)
case _ => false
}
result
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ class ParameterizedListValue(parameter: PrimitiveType)

val Separator: String = " "

override def getType: PrimitiveType = { new ParameterizedListType(this.parameter) }
override def getType: PrimitiveType = {
new ParameterizedListType(this.parameter)
}

def add(str: String): Unit = {
this += this.parameter.parse(str)
Expand All @@ -40,12 +42,12 @@ class ParameterizedListValue(parameter: PrimitiveType)
override def renderAsList(): Seq[String] = {
val list = new mutable.ArrayBuffer[String]()
this.foreach(elem => list += elem.render())
val result: Seq[String] = list.toList
val result = list.toList
result
}

override def compareTo(obj: PrimitiveTypeValue): Int = {
var result: Int = obj match {
val result: Int = obj match {
case other: ParameterizedListValue =>
val diff: Int = size - other.size
if (diff == 0) {
Expand All @@ -59,7 +61,9 @@ class ParameterizedListValue(parameter: PrimitiveType)
result
}

def getParameter: PrimitiveType = { this.parameter }
def getParameter: PrimitiveType = {
this.parameter
}

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ class SimplifiedCompositeType(dataType: CompositeTypeImpl) extends CompositeType
this.dataType.getFields
}

def getDataType: CompositeTypeImpl = dataType
def getDataType: CompositeTypeImpl = {
dataType
}

override def getFieldType(field: String): Option[String] = {
this.dataType.getFieldType(field)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@

package de.tudresden.inf.lat.tabulas.datatype

import scala.collection.mutable

/** This models a string value.
*
*/
Expand All @@ -13,42 +11,40 @@ class StringValue(str: String) extends PrimitiveTypeValue {
new StringType()
}

def getValue: String = str
def getValue: String = {
str
}

override def isEmpty: Boolean = {
this.str.trim().isEmpty
str.trim().isEmpty
}

override def render(): String = {
this.str
str
}

override def renderAsList(): Seq[String] = {
val list = new mutable.ArrayBuffer[String]()
list += render()
val result: Seq[String] = list.toList
result
List(render())
}

override def compareTo(other: PrimitiveTypeValue): Int = {
toString.compareTo(other.toString)
}

override def hashCode(): Int = {
this.str.hashCode()
str.hashCode()
}

override def equals(obj: Any): Boolean = {
var result: Boolean = false
obj match {
case other: StringValue => result = this.str.equals(other.getValue)
case _ => result = false
val result = obj match {
case other: StringValue => str.equals(other.getValue)
case _ => false
}
result
}

override def toString: String = {
this.str
str
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ package de.tudresden.inf.lat.tabulas.datatype
import java.net.{URI, URISyntaxException}
import java.util.Objects

import scala.collection.mutable

/** This models a URI.
*
*/
Expand All @@ -18,29 +16,27 @@ class URIValue(uri: URI) extends PrimitiveTypeValue {
}

def getUri: URI = {
this.uri
uri
}

def getUriNoLabel: URI = {
val uriStr: String = this.uri.toASCIIString
val pos: Int = uriStr.lastIndexOf(SpecialSymbol)
var result: URI = this.uri
if (pos == -1) {
result = this.uri
val result: URI = if (pos == -1) {
uri
} else {
result = URIValue.createURI(uriStr.substring(0, pos))
URIValue.createURI(uriStr.substring(0, pos))
}
result
}

def getLabel: String = {
val uriStr: String = this.uri.toASCIIString
val pos: Int = uriStr.lastIndexOf(SpecialSymbol)
var result: String = ""
if (pos == -1) {
result = ""
val result: String = if (pos == -1) {
""
} else {
result = uriStr.substring(pos + SpecialSymbol.length())
uriStr.substring(pos + SpecialSymbol.length())
}
result
}
Expand All @@ -50,29 +46,25 @@ class URIValue(uri: URI) extends PrimitiveTypeValue {
}

override def render(): String = {
this.uri.toASCIIString
uri.toASCIIString
}

override def renderAsList(): Seq[String] = {
val list = new mutable.ArrayBuffer[String]()
list += render()
val result: Seq[String] = list.toList
result
List(render())
}

override def compareTo(other: PrimitiveTypeValue): Int = {
toString.compareTo(other.toString)
}

override def hashCode(): Int = {
this.uri.hashCode()
uri.hashCode()
}

override def equals(obj: Any): Boolean = {
var result: Boolean = false
obj match {
case other: URIValue => result = getUri.equals(other.getUri)
case _ => result = false
val result = obj match {
case other: URIValue => getUri.equals(other.getUri)
case _ => false
}
result
}
Expand Down Expand Up @@ -116,9 +108,8 @@ object URIValue {
}

def createURI(uriStr: String): URI = {
var result: URI = URI.create("")
try {
result = new URI(uriStr)
val result: URI = try {
new URI(uriStr)
} catch {
case e: URISyntaxException => throw new ParseException("Invalid URI '" + uriStr + "'.", e)
}
Expand Down
Loading

0 comments on commit 802c22d

Please sign in to comment.