Skip to content
Permalink
Browse files
refactor: reformatting Scala files (DSP-1897) (#1908)
* refactor: apply ZIO formating rules

* chore: change formatting config
  • Loading branch information
mpro7 committed Sep 23, 2021
1 parent 689d92a commit 8df70a27c85a25237425f9a7a181d84fb121870a
Showing 405 changed files with 59,263 additions and 54,872 deletions.

This file was deleted.

@@ -1,6 +1,6 @@
version = "2.7.5"
maxColumn = 120
align.preset = most
align.preset = some
align.multiline = false
continuationIndent.defnSite = 2
assumeStandardLibraryStripMargin = true
@@ -20,8 +20,8 @@
package org.knora.webapi

/**
* Constants for language codes.
*/
* Constants for language codes.
*/
object LanguageCodes {
val DE: String = "de"
val EN: String = "en"
@@ -20,131 +20,127 @@
package org.knora.webapi

/**
* Indicates the schema that a Knora ontology or ontology entity conforms to.
*/
* Indicates the schema that a Knora ontology or ontology entity conforms to.
*/
sealed trait OntologySchema

/**
* The schema of Knora ontologies and entities that are used in the triplestore.
*/
* The schema of Knora ontologies and entities that are used in the triplestore.
*/
case object InternalSchema extends OntologySchema

/**
* The schema of Knora ontologies and entities that are used in API v2.
*/
* The schema of Knora ontologies and entities that are used in API v2.
*/
sealed trait ApiV2Schema extends OntologySchema

/**
* The simple schema for representing Knora ontologies and entities. This schema represents values as literals
* when possible.
*/
* The simple schema for representing Knora ontologies and entities. This schema represents values as literals
* when possible.
*/
case object ApiV2Simple extends ApiV2Schema

/**
* The default (or complex) schema for representing Knora ontologies and entities. This
* schema always represents values as objects.
*/
* The default (or complex) schema for representing Knora ontologies and entities. This
* schema always represents values as objects.
*/
case object ApiV2Complex extends ApiV2Schema

/**
* A trait representing options that can be submitted to configure an ontology schema.
*/
* A trait representing options that can be submitted to configure an ontology schema.
*/
sealed trait SchemaOption

/**
* A trait representing options that affect the rendering of markup when text values are returned.
*/
* A trait representing options that affect the rendering of markup when text values are returned.
*/
sealed trait MarkupRendering extends SchemaOption

/**
* Indicates that markup should be rendered as XML when text values are returned.
*/
* Indicates that markup should be rendered as XML when text values are returned.
*/
case object MarkupAsXml extends MarkupRendering

/**
* Indicates that markup should not be returned with text values, because it will be requested
* separately as standoff.
*/
* Indicates that markup should not be returned with text values, because it will be requested
* separately as standoff.
*/
case object MarkupAsStandoff extends MarkupRendering

/**
* Indicates that no markup should be returned with text values. Used only internally.
*/
* Indicates that no markup should be returned with text values. Used only internally.
*/
case object NoMarkup extends MarkupRendering

/**
* A trait representing options that affect the format of JSON-LD responses.
*/
* A trait representing options that affect the format of JSON-LD responses.
*/
sealed trait JsonLDRendering extends SchemaOption

/**
* Indicates that flat JSON-LD should be returned, i.e. objects with IRIs should be referenced by IRI
* rather than nested. Blank nodes will still be nested in any case.
*/
* Indicates that flat JSON-LD should be returned, i.e. objects with IRIs should be referenced by IRI
* rather than nested. Blank nodes will still be nested in any case.
*/
case object FlatJsonLD extends JsonLDRendering

/**
* Indicates that hierarchical JSON-LD should be returned, i.e. objects with IRIs should be nested when
* possible, rather than referenced by IRI.
*/
* Indicates that hierarchical JSON-LD should be returned, i.e. objects with IRIs should be nested when
* possible, rather than referenced by IRI.
*/
case object HierarchicalJsonLD extends JsonLDRendering

/**
* Utility functions for working with schema options.
*/
* Utility functions for working with schema options.
*/
object SchemaOptions {

/**
* A set of schema options for querying all standoff markup along with text values.
*/
* A set of schema options for querying all standoff markup along with text values.
*/
val ForStandoffWithTextValues: Set[SchemaOption] = Set(MarkupAsXml)

/**
* A set of schema options for querying standoff markup separately from text values.
*/
* A set of schema options for querying standoff markup separately from text values.
*/
val ForStandoffSeparateFromTextValues: Set[SchemaOption] = Set(MarkupAsStandoff)

/**
* Determines whether standoff should be queried when a text value is queried.
*
* @param targetSchema the target API schema.
* @param schemaOptions the schema options submitted with the request.
* @return `true` if standoff should be queried.
*/
def queryStandoffWithTextValues(targetSchema: ApiV2Schema, schemaOptions: Set[SchemaOption]): Boolean = {
* Determines whether standoff should be queried when a text value is queried.
*
* @param targetSchema the target API schema.
* @param schemaOptions the schema options submitted with the request.
* @return `true` if standoff should be queried.
*/
def queryStandoffWithTextValues(targetSchema: ApiV2Schema, schemaOptions: Set[SchemaOption]): Boolean =
targetSchema == ApiV2Complex && !schemaOptions.contains(MarkupAsStandoff)
}

/**
* Determines whether markup should be rendered as XML.
*
* @param targetSchema the target API schema.
* @param schemaOptions the schema options submitted with the request.
* @return `true` if markup should be rendered as XML.
*/
def renderMarkupAsXml(targetSchema: ApiV2Schema, schemaOptions: Set[SchemaOption]): Boolean = {
* Determines whether markup should be rendered as XML.
*
* @param targetSchema the target API schema.
* @param schemaOptions the schema options submitted with the request.
* @return `true` if markup should be rendered as XML.
*/
def renderMarkupAsXml(targetSchema: ApiV2Schema, schemaOptions: Set[SchemaOption]): Boolean =
targetSchema == ApiV2Complex && !schemaOptions.contains(MarkupAsStandoff)
}

/**
* Determines whether markup should be rendered as standoff, separately from text values.
*
* @param targetSchema the target API schema.
* @param schemaOptions the schema options submitted with the request.
* @return `true` if markup should be rendered as standoff.
*/
def renderMarkupAsStandoff(targetSchema: ApiV2Schema, schemaOptions: Set[SchemaOption]): Boolean = {
* Determines whether markup should be rendered as standoff, separately from text values.
*
* @param targetSchema the target API schema.
* @param schemaOptions the schema options submitted with the request.
* @return `true` if markup should be rendered as standoff.
*/
def renderMarkupAsStandoff(targetSchema: ApiV2Schema, schemaOptions: Set[SchemaOption]): Boolean =
targetSchema == ApiV2Complex && schemaOptions.contains(MarkupAsStandoff)
}

/**
* Determines whether flat JSON-LD should be returned, i.e. objects with IRIs should be referenced by IRI
* rather than nested.
*
* @param schemaOptions the schema options submitted with the request.
* @return `true` if flat JSON-LD should be returned.
*/
def returnFlatJsonLD(schemaOptions: Set[SchemaOption]): Boolean = {
* Determines whether flat JSON-LD should be returned, i.e. objects with IRIs should be referenced by IRI
* rather than nested.
*
* @param schemaOptions the schema options submitted with the request.
* @return `true` if flat JSON-LD should be returned.
*/
def returnFlatJsonLD(schemaOptions: Set[SchemaOption]): Boolean =
schemaOptions.contains(FlatJsonLD)
}
}
@@ -22,9 +22,9 @@ package org.knora.webapi
import akka.http.scaladsl.model.{ContentType, HttpCharsets, MediaType, MediaTypes}

/**
* Represents media types supported by the Knora API server for representing RDF data, and provides
* convenience methods for transforming media types.
*/
* Represents media types supported by the Knora API server for representing RDF data, and provides
* convenience methods for transforming media types.
*/
object RdfMediaTypes {
val `application/json`: MediaType.WithFixedCharset = MediaTypes.`application/json`

@@ -63,8 +63,8 @@ object RdfMediaTypes {
)

/**
* A map of MIME types (strings) to supported RDF media types.
*/
* A map of MIME types (strings) to supported RDF media types.
*/
val registry: Map[String, MediaType.NonBinary] = Set(
`application/json`,
`application/ld+json`,
@@ -77,29 +77,27 @@ object RdfMediaTypes {
}.toMap

/**
* Ensures that a media specifies the UTF-8 charset if necessary.
*
* @param mediaType a non-binary media type.
* @return the same media type, specifying the UTF-8 charset if necessary.
*/
def toUTF8ContentType(mediaType: MediaType.NonBinary): ContentType.NonBinary = {
* Ensures that a media specifies the UTF-8 charset if necessary.
*
* @param mediaType a non-binary media type.
* @return the same media type, specifying the UTF-8 charset if necessary.
*/
def toUTF8ContentType(mediaType: MediaType.NonBinary): ContentType.NonBinary =
mediaType match {
case withFixedCharset: MediaType.WithFixedCharset => withFixedCharset.toContentType
case withOpenCharset: MediaType.WithOpenCharset => withOpenCharset.toContentType(HttpCharsets.`UTF-8`)
}
}

/**
* Converts less specific media types to more specific ones if necessary (e.g. specifying
* JSON-LD instead of JSON).
*
* @param mediaType a non-binary media type.
* @return the most specific similar media type that the Knora API server supports.
*/
def toMostSpecificMediaType(mediaType: MediaType.NonBinary): MediaType.NonBinary = {
* Converts less specific media types to more specific ones if necessary (e.g. specifying
* JSON-LD instead of JSON).
*
* @param mediaType a non-binary media type.
* @return the most specific similar media type that the Knora API server supports.
*/
def toMostSpecificMediaType(mediaType: MediaType.NonBinary): MediaType.NonBinary =
mediaType match {
case `application/json` => `application/ld+json`
case other => other
}
}
}
@@ -20,24 +20,23 @@
package org.knora.webapi.annotation

/**
* Creates the ApiMayChange annotation.
*
* Marks APIs that are meant to evolve towards becoming stable APIs, but are not stable APIs yet.
*
* <p>Evolving interfaces MAY change from one patch release to another (i.e. 2.4.10 to 2.4.11)
* without up-front notice. A best-effort approach is taken to not cause more breakage than really
* necessary, and usual deprecation techniques are utilised while evolving these APIs, however there
* is NO strong guarantee regarding the source or binary compatibility of APIs marked using this
* annotation.
*
* <p>It MAY also change when promoting the API to stable, for example such changes may include
* removal of deprecated methods that were introduced during the evolution and final refactoring
* that were deferred because they would have introduced to much breaking changes during the
* evolution phase.
*
* <p>Promoting the API to stable MAY happen in a patch release.
*
* <p>It is encouraged to document in ScalaDoc how exactly this API is expected to evolve.
*
*/
* Creates the ApiMayChange annotation.
*
* Marks APIs that are meant to evolve towards becoming stable APIs, but are not stable APIs yet.
*
* <p>Evolving interfaces MAY change from one patch release to another (i.e. 2.4.10 to 2.4.11)
* without up-front notice. A best-effort approach is taken to not cause more breakage than really
* necessary, and usual deprecation techniques are utilised while evolving these APIs, however there
* is NO strong guarantee regarding the source or binary compatibility of APIs marked using this
* annotation.
*
* <p>It MAY also change when promoting the API to stable, for example such changes may include
* removal of deprecated methods that were introduced during the evolution and final refactoring
* that were deferred because they would have introduced to much breaking changes during the
* evolution phase.
*
* <p>Promoting the API to stable MAY happen in a patch release.
*
* <p>It is encouraged to document in ScalaDoc how exactly this API is expected to evolve.
*/
class ApiMayChange() extends scala.annotation.StaticAnnotation
@@ -20,9 +20,8 @@
package org.knora.webapi.annotation

/**
* Creates the ProjectUnique annotation.
*
* Marks values which need to be unique on the level of the PROJECT.
*
*/
* Creates the ProjectUnique annotation.
*
* Marks values which need to be unique on the level of the PROJECT.
*/
class ProjectUnique() extends scala.annotation.StaticAnnotation
@@ -20,9 +20,8 @@
package org.knora.webapi.annotation

/**
* Creates the ServerUnique annotation.
*
* Marks values which need to be unique on the level of the SERVER.
*
*/
* Creates the ServerUnique annotation.
*
* Marks values which need to be unique on the level of the SERVER.
*/
class ServerUnique() extends scala.annotation.StaticAnnotation

0 comments on commit 8df70a2

Please sign in to comment.