enums

Adding an enum as a class property in HBM.

I am trying to create a class in HBM file which contains an Enum as a field. The HBM is similar to this: <class name="a.b.c.myObject" table="OBJECT" > <property name="myEnum" column="EXAMPLE" type="a.b.c.myEnum" /> </class> and let's say that this is the Enum: public enum myEnum{ a, b, c; } The problem is that in the DB...

Find Enum Value by Passed Parameter

Hi, I have an enum like this : public enum Priority { Low = 0, Medium = 1, Urgent = 2 } And I want to get the for example Priority.Low by passing like Enum.GetEnumVar(Priority,0) which should return Priority.Low How can I accomplish that ? Thank you in advance. ...

Retrieve value of Enum based on index - c#

This is my enum: public enum DocumentTypes { [EnumMember] TYPE_1 = 1, [EnumMember] TYPE_2 = 2, [EnumMember] TYPE_3 = 3, [EnumMember] TYPE_4 = 4, [EnumMember] TYPE_5 = 5, [EnumMember] TYPE_6 = 6, [EnumMember] TYPE_7 = 7, ...

can C# enums be declared as of bool type?

Hi, Can I declare c# enum as bool like: enum Result : bool { pass = true, fail = false } ...

Getting a property from an representation of it

I have some doubt about the title, but I couldn't come up with anything better. Say I have the following enum public enum ClassProperties { Primary = 0, Secondary = 1, } And a class that looks this public class Test { Primary { get { return _primary; }} Secondary { get { return _secondary; }} // more irrelevant...

Best way of emulating enum in Ruby? (part two)

Hello, I'm new to Ruby so forgive me if this is something obvious.. I've made a class like so class Element attr_accessor :type :type_integer :type_string end (this is really just an example, not actual code) Well, I've read http://stackoverflow.com/questions/75759/enums-in-ruby and I'd prefer to go the Symbols route of having...

Getting the integer value from enum

I am working on a basic Battleship game to help my C# skills. Right now I am having a little trouble with enum. I have: enum game : int { a=1, b=2, c=3, } I would like the player to pass the input "C" and some code return the integer 3. How would I set it up for it to take a string var (string pick;) and convert it to th...

How to write Java-like enums in C++ ?

Coming from Java background, I find C++'s enums very lame. I wanted to know how to write Java-like enums (the ones in which the enum values are objects, and can have attributes and methods) in C++. As an example, translate the following Java code (a part of it, sufficient to demonstrate the technique) to C++ : public enum Planet { ...

Enumerations in python

Duplicate: Whats the best way to implement an enum in Python? Whats the recognised way of doing enumerations in python? For example, at the moment I'm writing a game and want to be able to move "up", "down", "left" and "right". I'm using strings because I haven't yet figured out how enumerations work in python, and so my logic...

Grails GORM & Enums

I've a problem using Enumeration in Grails: I try to use an enumeraion in a grails domain object code: package it.xxx.tools.kanban import java.util.Date; class Task { String name String description Priority priority static belongsTo = [user:User, project:Project] static constraints = {...

Enums or Tables?

I am making this a community wiki, as I would appreciate people's approach and not necessarily an answer. I am in the situation where I have a lot of lookup type data fields, that do not change. An example would be: Yearly Salary Option: 0 - 25K Option: 25K - 100K Option: 100K + I would like to have these options easily ava...

Reference to Public Enum results in Anonymous Class

I'm getting an anonymous class at compile-time that I'm not expecting. Relevant code follows, then a more detailed explanation: Entirety of CircuitType.java: public enum CircuitType { V110A20, V110A30, V208A20, V208A30 } From Auditor.java, lines 3-9: public class Auditor { private String[] fileNames; private int numV110A20; ...

How to represent countries and languages in C#?

I will retrieve this data from an xml to initialize it for thousands of objects. So if MyObject has a Country and Language property, what should they be, and how should they be represented both in code and in xml. I am thinking of using an Enum in code. I am just looking for other people's opinions to find the best way to do this. Is ...

Java: Pick a random value from an enum?

If I have an enum like this: public enum Letter { A, B, C, //... } What is the best way to pick one randomly? It doesn't need to be production quality bulletproof, but a fairly even distribution would be nice. I could do something like this private Letter randomLetter() { int pick = new Random().nextInt(Letter.va...

What should I name an enum describing whether a field is hidden, optional, or required?

I have a control with a bunch of fields that I want a user to be able to configure. I originally had this: public bool Phone1Visible; public bool Phone1Required; Then realized that I didn't want to deal with having to validate again hidden required fields, so I came up with this: public enum YOUR_NAME_HERE { Hidden, ...

Hibernate/JPA/HSQLDB Enum issues...

I am using Hibernate annotations and entity manager (JPA) with HSQLDB. So I have an entity with an enum field: @Enumerated(EnumType.STRING) @Column(name = "access_level") public AccessLevel getAccessLevel() { return accessLevel; } Where AccessLevel is an enum. I can persist this, detach, and then query and everything is as it sho...

Using enums as parameters in an external file in Objective-C?

I have an enum named RandomEnum in file foo.h: // foo.h typedef enum RandomEnum { ran_1 = 0, ran_2 } RandomEnum; In another file, bar.h, I'm trying to use RandomEnum as a parameter type: // bar.h #import "foo.h" @interface bar : NSObject {} -(RandomEnum)echo:(RandomEnum)ran; @end However, the compiler doesn't seem to recogni...

Please help.. to create a enum or enum type functionality witch return string (enum returns int) in .net

i have a URL lets say . some time i need to send HTTP and some time i need to send it to HTTPS for that i created a enum: Private _protocol As Protocol Enum Protocol HTTP HTTPS End Enum Public Property protocolType() As Protocol Get Return _protocol End Get Set(ByVal value As Protocol) _protocol = v...

how to use enum with jpa as a data member of persisted entity ?

Hi, Please best practice and 'how to' for using enum with jpa as a data member of persisted entity. what is the best practice? I want to persist "C", "O" from enum. (codes). If this is not the correct approach please suggest. Enum defination is -- public enum Status{ CLOSED ("C") OPEN ("O") private final int value; private Status(fina...

How can include a dot character in enum type name in javascript?

Hi all, I'm using javascript and have this enumeration: filterType = { Campaign : 'Campaign', Class : 'Class', Date : 'Date', DateGeq : 'DateGeq', DateLeq : 'DateLeq', DateRange : 'DateRange', Status : 'Status' } I'd like to name it as: Filter.filterType = { Campaign : 'Campaign', Class : 'Class', Dat...