Category "enums"

How to use custom labels from Django models.Choices field together with enum.auto?

Before Django v3.0 I used to use enum.Enum together with enum.auto (see reference) for my choices fields. The reason was mostly so I could use my enumeration cl

Create macro to simplify declaration of deeply nested enum?

I want to use deeply nested enums to represent blocks in my game: enum Element { Void, Materal(Material) } enum Material { Gas(Gas), NonGas(NonGas) } enum NonGa

declare and using enum class and using in one statement

When using scoped enums I stumbled over some syntax which is accepted by Microsoft, but not by clang or gcc: using enum class Color { RED, GREEN, BLUE }; (ht

How to use same enum in multiple files in Typescript without import

I've been struggling with this now longer than I should and surprisingly, the existing questions (and there are many) don't really help further. My goal is to d

Is there a solution for a bitwise logical AND (&) operator between two Enum values in C#

Consider the following simple Flags Enum in C#: [Flags] public enum CountingEnum { Zero = 0, One = 1 << 0, Two = 1 << 1, Three = Two

Is there a neat way of converting lists into maps with the keys set to the elements of original collection and values set to an enum in java

Java newbie... I have a dictionary like so: electronictypeModelsMap = { "laptops" => ["macbook", "thinkpad", "yoga"], "desktops" => ["macmini", "imac", "o

How to accept multiple objects into an array NestJS

I have a feedbackQuestion schema which takes (title: string, subtitle: string, types: enum, values: enum) import { Prop, Schema, SchemaFactory } from '@nestjs/m

OpenApi enum with multiple values

I am new to OpenApi and want to define my api with an api.yaml (OpenApi version 3.0.1). My problem is the generated enum just contains the name and not the valu

How to check if enum type?

How can I tell if a variable is of type enum? I have installed PHP 8.1 on my Ubuntu 20.04. I'm testing the new "enum" types. Is something like that possible? is

Non-nullable enum as generic parameter [duplicate]

I am trying to implement this helper function in C# 7.3: public static T? ToEnum<T>(this string enumName) where T : Enum =>

Type hint for an exhaustive dictionary with Enum/Literal keys

I'm working on code bases with extensive type hints, checked by mypy. There's several instances where we have a mapping from an enum.Enum or other small finite

Laravel 8: How to set default value of all enum values

I want to assign all default values for allowed_file_types column in products table which are all values of enum FileTypes. But now I have no way to do that. Ca

Why can't the instance member be accessed from the lambda of the enum constructor?

In the code below, I am trying to output the value of a symbol that is an instance variable of Operation from a PLUS constant. But I can't access that variable.

Conflicting enum values java

I have 2 enums defined as below in 2 separate files: MyErrorCodes.java @Getter public enum MyErrorCodes implements ErrorCode { ERROR1(90, 1, 01), ERROR2

C#; How to Loop Through/Wrap Enumerations when Incremented?

Say you have a byte value equal to its max value, so byte aByte = 255;. When you increment a value past its max value, it usually wraps around to its minimum va

How to set enum in datatable ColumnProperty of nopcommerce 4.4

I want to set enum in datatable ColumnProperty of nopcommerce 4.4. I tried things like new ColumnProperty(nameof(await(((TransmitEnumStatus)Model.StatusId).ToSe

In a Java interface, is there a way to return an enum nested in a generic type?

I'm looking for a way to return an Enum type nested in a Generic class. Here's what I mean: public interface MapperClass<E, D> { D entityToDto(E enti

Troubleshooting enums with efcore.pg

Are there any best practices in troubleshooting enums when using with Npgsql.EntityFrameworkCore.PostgreSQL provider? It's just that I don't know where to look

In json schema, how to define an enum with description of each elements in the enum?

In json schema, I can simply define a code list using "enum" with a list of code that is available, for example: { "type": "object", "properties": { "gr

Automapper with EnumMapping throws on nullable Enums with unknown value

I have a nullable enum property on the source side and get this property with value 0 instead of NULL. But 0 is not a represented value in the enum so AutoMappe