IDEA-CR-1731 Use UnsupportedOperationException

This commit is contained in:
Vladimir Krivosheev
2017-01-13 16:16:56 +01:00
parent 4ca4c3c78f
commit 3ab461f899
2 changed files with 19 additions and 15 deletions
@@ -54,14 +54,22 @@ abstract class BaseState : SerializationFilter, ModificationTracker {
return result
}
override fun equals(other: Any?): Boolean {
if (this === other) return true
if (other !is BaseState) return false
return properties == other.properties
}
override fun equals(other: Any?) = this === other || (other is BaseState && properties == other.properties)
override fun hashCode() = properties.hashCode()
override fun toString(): String {
if (properties.isEmpty()) {
return ""
}
val builder = StringBuilder()
for (property in properties) {
builder.append(property.value).append(" ")
}
builder.setLength(builder.length - 1)
return builder.toString()
}
}
internal class StoredProperty<T>(internal val defaultValue: T?) : ReadWriteProperty<BaseState, T?> {
@@ -80,13 +88,9 @@ internal class StoredProperty<T>(internal val defaultValue: T?) : ReadWritePrope
}
}
override fun equals(other: Any?): Boolean {
if (this === other) return true
if (other !is StoredProperty<*>) return false
if (value != other.value) return false
return true
}
override fun equals(other: Any?) = this === other || (other is StoredProperty<*> && value == other.value)
override fun hashCode() = value?.hashCode() ?: 0
override fun toString() = value?.toString() ?: super.toString()
}
@@ -67,7 +67,7 @@ public abstract class ModuleExtension implements Disposable, Comparable<ModuleEx
*/
@Deprecated
public void readExternal(@NotNull Element element) {
throw new Error("Please implement PersistentStateComponent");
throw new UnsupportedOperationException("Implement PersistentStateComponent");
}
/**
@@ -75,6 +75,6 @@ public abstract class ModuleExtension implements Disposable, Comparable<ModuleEx
*/
@Deprecated
public void writeExternal(@NotNull Element element) {
throw new Error("Please implement PersistentStateComponent");
throw new UnsupportedOperationException("Implement PersistentStateComponent");
}
}