Posts

Kotlin - How to make field read-only for external classes -

i have following kotlin class on android: class thisapplication: application() { lateinit var network: inetwork override fun oncreate() { super.oncreate() network = network() } } now, external class can inetwork reference doing: application.network however, makes possible external class overwrite value: application.network = mynewnetworkreference i want avoid second option. unfortunately, can't make field val because initialization needs happen inside oncreate callback. i thought making field private , exposing through function, this: private lateinit var network: inetwork fun getnetwork() = network however, whoever calls getnetwork() can still assign new value it, so: application.getnetwork() = mynewnetworkreference how can make network field read-only external classes? or better, there way make val though can't initialize inside constructor? to restrict access external classes, can change visibility of acce...

linux - Credit-Based Process Scheduling algorithm -

i've been trying implement in java simulation of the credit based scheduler algorithm not understand logic of algorithm i referring : credit-based algorithm – each task has # of credits associated – on each timer interrupt: • each timer interrupt: running task loses 1 credit • if credits task == 0, task suspended • if tasks have 0 credits: – re-credit: every task gets credits = credits/2 + priority choose next task run: pick 1 credits my question : when credits = 0 :====> use formula recredits processes credits = credits/2 +priority how can use credits since equals 0 ?, should use self-defined table of credits ? or misunderstanding help, please?

javascript - Write a function called 'maker' that creates an array and fills that array with numbers 1 to 25, then returns the array -

question write function called 'maker' creates array , fills array numbers 1 25, returns array i'm stuck on problem, i've watched bunch of videos, , read various forms, can't seem figure out. can me? my attempt var myarray = [1-25] function maker(arr) { return myarray } try this: function maker() { var myarray = []; (var = 0; < 25; i++) { myarray[i] = + 1; } return myarray; } hope helps!

C++ how to compact fancy for-loops -

if 1 lazy rewrite fancy loop on variable u, 1 can define macro this: #define forloop(u) (int u = 0; u < n; u++) now, let's want this for (int u = 0; u < n; u++) { class& var_u = somefunctionof(u) ... code using var_u ... } and let's need @ several places in code, , lazy rewrite it, because loop involves complicated conditions on multiple variables. how can compress macro ? feel annoying put 1 { in macro because whatever ide using break syntax highlighting , everything... i had idea: define template: template <typename loop> void forloop(int u, const loop& loop) { (int u = 0; u < n; u++) { class& var_u = somefunctionof(u) loop(u, var_u); } } so have write: forloop([&](int u, class& var_u){ ... code using var_u ... }); i know, i'm weird. idea? inlined 100% of time? not lose performance doing instead of regular loop? performance critical in case. other way thought about: #define fo...

Why Java EE jsessionID changed after a click -

i'm learning java ee servlets. when log in page http://localhost:8080/test/login jsessionid a. click link http://localhost/test/buy?book=java&price=99.9” , jsessionid changed b. please give me guidance.

java - Eclipse Neon.3 / error dialog window pops up after clicking on WildFly @ Servers-Tab -

i'm asking help: eclipse neon.3 release (4.6.3): everytime when click in servers-tab on wildfly 10 server error dialog window, there no errors in console-output. deploying , other functions in eclipse behave fine. but how rid of error dialog popup?: an error has occurred. see error log more details. bad type on operand stack exception details: location: com/spotify/docker/client/defaultdockerclient.copycontainer(ljava/lang/string;ljava/lang/string;)ljava/io/inputstream; @43: invokevirtual reason: type 'com/fasterxml/jackson/databind/node/textnode' (current frame, stack[2]) not assignable 'com/fasterxml/jackson/databind/jsonnode' current frame: bci: @43 flags: { } locals: { 'com/spotify/docker/client/defaultdockerclient', 'java/lang/string', 'java/lang/string', 'javax/ws/rs/client/webtarget', 'com/fasterxml/jackson/databind/node/jsonnodefactory' } stack: { 'com/fasterxml/jackson/dat...

java - ConstraintViolationException: Validation failed for classes [....entities.WalletInfo] during persist -

Image
i work spring mvc restful app , constraintviolationexception while persisting. error message provided below, exception in thread " starting" javax.validation.constraintviolationexception: validation failed classes [mobi.puut.entities.walletinfo] during persist time groups [javax.validation.groups.default, ] list of constraint violations:[ constraintviolationimpl{interpolatedmessage='may not null', propertypath=id, rootbeanclass=class mobi.puut.entities.walletinfo, messagetemplate='{javax.validation.constraints.notnull.message}'} constraintviolationimpl{interpolatedmessage='may not null', propertypath=currency, rootbeanclass=class mobi.puut.entities.walletinfo, messagetemplate='{javax.validation.constraints.notnull.message}'} ] @ org.hibernate.cfg.beanvalidation.beanvalidationeventlistener.validate(beanvalidationeventlistener.java:140) @ org.hibernate.cfg.beanvalidation.beanvalidationeventlistener.onpreinsert(beanvalidat...