All Downloads are FREE. Search and download functionalities are using the official Maven repository.

lucuma.itc.input.odb.GmosCustomMaskInput.scala Maven / Gradle / Ivy

There is a newer version: 0.22.3
Show newest version
// Copyright (c) 2016-2023 Association of Universities for Research in Astronomy, Inc. (AURA)
// For license information see LICENSE or https://opensource.org/licenses/BSD-3-Clause

package lucuma.odb.graphql
package input

import cats.syntax.parallel.*
import eu.timepit.refined.types.string.NonEmptyString
import grackle.Result
import lucuma.core.model.sequence.gmos.GmosFpuMask.Custom
import lucuma.odb.graphql.binding.*

object GmosCustomMaskInput {

  val Binding: Matcher[Custom] =
    ObjectFieldsBinding.rmap {
      case List(
            StringBinding("filename", rFilename),
            GmosCustomSlitWidthBinding("slitWidth", rSlitWidth)
          ) =>
        (rFilename, rSlitWidth).parTupled.flatMap { (filename, slitWidth) =>
          NonEmptyString.from(filename) match {
            case Left(_)  => Result.failure("The GMOS custom FPU mask 'filename' cannot be empty.")
            case Right(n) => Result(Custom(n, slitWidth))
          }
        }
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy