-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #390 from eed3si9n/wip/configref
intern/flyweight ConfigRef
- Loading branch information
Showing
7 changed files
with
112 additions
and
83 deletions.
There are no files selected for viewing
36 changes: 0 additions & 36 deletions
36
core/src/main/contraband-scala/sbt/librarymanagement/ConfigRef.scala
This file was deleted.
Oops, something went wrong.
27 changes: 0 additions & 27 deletions
27
core/src/main/contraband-scala/sbt/librarymanagement/ConfigRefFormats.scala
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
/** | ||
* This code is generated using [[https://www.scala-sbt.org/contraband/ sbt-contraband]]. | ||
*/ | ||
package sbt.librarymanagement | ||
|
||
import scala.collection.concurrent.TrieMap | ||
|
||
/** | ||
* A reference to Configuration. | ||
* @param name The name of the configuration that eventually get used by Maven. | ||
*/ | ||
final class ConfigRef private (val name: String) extends Serializable { | ||
|
||
override def equals(o: Any): Boolean = | ||
this.eq(o.asInstanceOf[AnyRef]) | ||
|
||
override val hashCode: Int = { | ||
37 * (37 * (17 + "sbt.librarymanagement.ConfigRef".##) + name.##) | ||
} | ||
|
||
override def toString: String = { | ||
name | ||
} | ||
|
||
private[this] def copy(name: String = name): ConfigRef = { | ||
ConfigRef(name) | ||
} | ||
|
||
def withName(name: String): ConfigRef = { | ||
copy(name = name) | ||
} | ||
} | ||
|
||
object ConfigRef extends sbt.librarymanagement.ConfigRefFunctions { | ||
// cache the reference to ConfigRefs | ||
private val cache = new TrieMap[String, ConfigRef] | ||
private lazy val Default = new ConfigRef("default") | ||
private lazy val Compile = new ConfigRef("compile") | ||
private lazy val IntegrationTest = new ConfigRef("it") | ||
private lazy val Provided = new ConfigRef("provided") | ||
private lazy val Runtime = new ConfigRef("runtime") | ||
private lazy val Test = new ConfigRef("test") | ||
private lazy val System = new ConfigRef("system") | ||
private lazy val Optional = new ConfigRef("optional") | ||
private lazy val Pom = new ConfigRef("pom") | ||
private lazy val ScalaTool = new ConfigRef("scala-tool") | ||
private lazy val ScalaDocTool = new ConfigRef("scala-doc-tool") | ||
private lazy val CompilerPlugin = new ConfigRef("plugin") | ||
private lazy val Component = new ConfigRef("component") | ||
private lazy val RuntimeInternal = new ConfigRef("runtime-internal") | ||
private lazy val TestInternal = new ConfigRef("test-internal") | ||
private lazy val IntegrationTestInternal = new ConfigRef("it-internal") | ||
private lazy val CompileInternal = new ConfigRef("compile-internal") | ||
|
||
def apply(name: String): ConfigRef = name match { | ||
case "default" => Default | ||
case "compile" => Compile | ||
case "it" => IntegrationTest | ||
case "provided" => Provided | ||
case "runtime" => Runtime | ||
case "test" => Test | ||
case "system" => System | ||
case "optional" => Optional | ||
case "pom" => Pom | ||
case "scala-tool" => ScalaTool | ||
case "scala-doc-tool" => ScalaDocTool | ||
case "plugin" => CompilerPlugin | ||
case "component" => Component | ||
case "runtime-internal" => RuntimeInternal | ||
case "test-internal" => TestInternal | ||
case "it-internal" => IntegrationTestInternal | ||
case "compile-internal" => CompileInternal | ||
case _ => cache.getOrElseUpdate(name, new ConfigRef(name)) | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
core/src/main/scala/sbt/librarymanagement/ConfigRefFormats.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/** | ||
* This code is generated using [[https://www.scala-sbt.org/contraband/ sbt-contraband]]. | ||
*/ | ||
package sbt.librarymanagement | ||
|
||
import _root_.sjsonnew.{ Unbuilder, Builder, JsonFormat, deserializationError } | ||
|
||
trait ConfigRefFormats { self: sjsonnew.BasicJsonProtocol => | ||
implicit lazy val ConfigRefFormat: JsonFormat[sbt.librarymanagement.ConfigRef] = | ||
new JsonFormat[sbt.librarymanagement.ConfigRef] { | ||
override def read[J]( | ||
__jsOpt: Option[J], | ||
unbuilder: Unbuilder[J] | ||
): sbt.librarymanagement.ConfigRef = { | ||
__jsOpt match { | ||
case Some(__js) => | ||
unbuilder.beginObject(__js) | ||
val name = unbuilder.readField[String]("name") | ||
unbuilder.endObject() | ||
sbt.librarymanagement.ConfigRef(name) | ||
case None => | ||
deserializationError("Expected JsObject but found None") | ||
} | ||
} | ||
override def write[J](obj: sbt.librarymanagement.ConfigRef, builder: Builder[J]): Unit = { | ||
builder.beginObject() | ||
builder.addField("name", obj.name) | ||
builder.endObject() | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters