Somebody explain me method chaining.

Hi.
I'm looking for somebody to give me an explanation of how does Method Chaining (I think this is how it's called) work.
i.e:
myObject.setPrice(2)
.setQuantity(10)
.solveLifeProblems()
.setAvailavility(true);
Where's the theory about this?
Can I do this with every class?
What requisites are needed so that I can use this technique with my classes?
What if the method, say solveLifeProblems() returns somethin strange (such as an boolean or another object)?
Thanks.

All you're doing is invoking a method on the return value of another method. All solveLiveProblems() has to do is return a class with a method called setAvailability.
Sodog()
.cat()
.monkey();is the same as
dog().cat().monkey();which is the same as (for example)
Hammer hammer = dog();
Screwdriver sd = hammer.cat();
sd.monkey();I'd advise not formatting your code like this until you have more experience.

Similar Messages

  • Can somebody explain to me how java and xml are related?

    Hi guys
    im new to java and xml.Been reading a lot regarding java and don't seem to have a problem with it...
    the problem is the xml part...im doing a simple GUI project using swing(online store) and i have to convert it to xml
    I have absolutely NO IDEA why i must convert my java to xml and have no idea how to do that.I been reading on the net that xml is a exten~ markup language and it is better and useful.
    Can somebody explain to me in layman terms
    1)how is java and xml related in?
    2)why do ppl want to convert java to xml when they can just stick to java
    3)what is actually xml...
    4)Do i need a program to create xml like i need jcreater to create java application
    5)How do we actually convert?is there any links that you guys could tell me?
    thank you
    tomleo

    im new to java and xml.Been reading a lot regarding
    java and don't seem to have a problem with it...Okay.
    the problem is the xml part...im doing a simple GUI
    project using swing(online store) and i have to
    o convert it to xmlYou have to? So presumably somebody in a position of authority told you that?
    I have absolutely NO IDEA why i must convert my java
    to xml and have no idea how to do that.I been reading
    on the net that xml is a exten~ markup language and
    it is better and useful.I have no idea either (besides which, it doesn't make sense). But why ask us? Somebody told you to do that, ask them why.
    Sure, XML is useful. But it isn't a programming language so it can't be used as a substitute for Java.
    Can somebody explain to me in layman terms
    1)how is java and xml related in?They aren't related, except perhaps in that they are both used in computers.
    2)why do ppl want to convert java to xml when they
    can just stick to javaThey don't.
    3)what is actually xml...Start here for numerous definitions:
    http://www.google.ca/search?hl=en&lr=&oi=defmore&q=define:XML
    4)Do i need a program to create xml like i need
    jcreater to create java applicationNo, XML is just text. But then Java code is just text too.
    5)How do we actually convert?is there any links that
    you guys could tell me?You don't convert Java to XML. My guess is that because you don't know much about Java or XML, you have misinterpreted something that somebody told you.

  • Could you please explain about the  chain and end chain and module

    hi experts
    could you please explain about the  chain and end chain and module keywords?

    Hi Naresh,
    Conditions for Multiple Screen Fields
    To ensure that one or more PAI modules are only called when several screen fields meet a particular condition, you must combine the calls in the flow logic to form a processing chain. You define processing chains as follows:
    CHAIN.
    ENDCHAIN.
    All flow logic statements between CHAIN and ENDCHAIN belong to a processing chain. The fields in the various FIELD statements are combined, and can be used in shared conditions.
    CHAIN.
    FIELD: <f1>, <f 2>,...
    MODULE <mod1> ON CHAIN-INPUT|CHAIN-REQUEST.
    FIELD: <g1>, <g 2>,...
    MODULE <mod2> ON CHAIN-INPUT|CHAIN-REQUEST.
    ENDCHAIN.
    The additions ON CHAIN-INPUT and ON CHAIN-REQUEST work like the additions ON INPUT and ON REQUEST that you use for individual fields. The exception is that the module is called whenever at least one of the fields listed in a preceding FIELD statement within the chain meets the condition. So <mod1> is called when one of the fields <fi> meets the condition. <mod2> is called when one of the fields <f i> or <g i> meets the condition.
    Within a processing chain, you can combine individual FIELD statements with a MODULE statement to set a condition for a single field within the chain:
    CHAIN.
    FIELD: <f1>, <f 2>,...
    FIELD <f> MODULE <mod1> ON INPUT|REQUEST|*-INPUT
    |CHAIN-INPUT|CHAIN-REQUEST.
    MODULE <mod2> ON CHAIN-INPUT|CHAIN-REQUEST.
    ENDCHAIN.
    The module <mod1> is called when screen field <f> meets the specified condition for individual fields. <mod2> is called when one of the fields <fi> or <f> meets the condition. If you use the addition ON CHAIN-INPUT or ON CHAIN-REQUEST with FIELD <f>, the condition also applies to the entire chain and module <mod1> and <mod2> are both called.
    In cases where you apply conditions to various combinations of screen fields, it is worth setting up a separate processing chain for each combination and calling different modules from within it.
    The functions of the FIELD statement for controlling data transport also apply when you use processing chains. Within a processing chain, screen fields are not transported until the FIELD statement. Processing chains also have another function for the FIELDS statements that they contain. This is described in the section on validity checks.
    Ex:
    PROCESS AFTER INPUT.
    MODULE CANCEL AT EXIT-COMMAND.
    CHAIN.
    FIELD: INPUT1, INPUT2.
    MODULE MODULE_1 ON CHAIN-INPUT.
    FIELD INPUT3 MODULE MODULE_* ON *-INPUT.
    MODULE MODULE_2 ON CHAIN-REQUEST.
    ENDCHAIN.
    FIELD INPUT1 MODULE C1 AT CURSOR-SELECTION.
    CHAIN.
    FIELD: INPUT2, INPUT3.
    MODULE C2 AT CURSOR-SELECTION.
    ENDCHAIN.
    MODULE CURSOR AT CURSOR-SELECTION.
    Regards,
    Sunil

  • Can somebody explain how dunning & hold are linked toghter

    In the IMG, i can not find out How dunning are linked with academic hold in the student file and can somebody explain how dunning is linked with academic hold.
    I defined hold type in IMG but i can not find out how to link with hold type with dunnng ?.
    regards,
    jin dal

    Dear Song,
    Answers to your queries are given below:
    Sample function module:
    u2022 Is only used as a template for creating the standard function modules to be carried out
    u2022 Defines the interface that is binding for the standard function modules
    u2022 Describes in its documentation what the underlying event can be used for
    Standard function module:
    Name of application-specific standard function module that can be carried out at a given time.
    The standard function module interface corresponds to the sample function module, which it must match exactly.
    Active function module:
    Function module which is to be called for the specified event.
    If you don't want to take printout then use Functional module 340 as Event 0340 is called when all data is read for a dunning notice.
    You can use standard function module FMCA_DUNNING_READ_ITEMS_0340 for this purpose.
    Hope it will solve your query.
    Warm Regards
    Vinod Kumar

  • Can somebody explain how ABC analysis is done ?

    Hi Experts,
                         Can somebody explain how ABC analysis is done . If I use MC40 transaction there I have 4option but I can use either one of those . For second option , Usage value as number we can directly specify cost and accordingly system will classify materials In A, B and C category .
    I have question on 1st 3 rd and 4 th option . How system will classify materials if These option is used .
    Please explain with examples .
    Points will be rewarded .
    Thanks in advance !
    Neal

    Hi Sir ,
                     Thanks again , I would explain what I have understood .
    MC 40 . Option selected is Usage value with value put are 70 , 20 , and 10 .
    Suppose I have 3 mat in plant
                  Stock         Value
    1) X        100 kg      1000   ( for 1 kg from MM)
    2) Y          20 PC      2300 
    3) Z          30  lt      40000
    Now how would system classify these items ? Will it consider price or only consumption /qty ? or both ?
    Please explain with the same figures . Again the 90 days period you said , is it taken automatically ? because on this T code there is no option for entering time period .
    Neal

  • Can somebody explain what the Radix number is in Character

    I am looking for a good way of converting numbers to characters and I was reading up on the Character API, and they are using this term Radix, and I don't understand what that is all about. Can somebody explain what the radix is for?

    Wait a second I tried this code out and this is the output
    System.err.println(Character.digit('a', 10));and i get a -1, which means "not a valid digit in the specified radix.
    Then I tried other combinations like
    System.err.println(Character.digit('a', 11));
    System.err.println(Character.digit('b', 12));
    System.err.println(Character.digit('c', 13));and they all work, and but with only those sequential characters and numbers. So right now I am very confused as to what this radix, or this function serves. Can somebody explain?

  • Can somebody explain to me how I can detect that an internet connection exists (VB)?

    Can somebody explain to me how I can detect that an internet connection exists (VB)?
    Peter Goossens

    There is no reliable way. Better test whether you can go to where you want to go. And be prepared to support proxies, even the complex ones that require authentication. 
    System.Net.NetworkInformation.NetworkInterface.GetIsNetworkAvailable reports your local connectivity regardless of whether one of your connected networks has Internet access.
    Microsoft's Network Awareness API (the one used in control panel\network and sharing center) use a connection test to a web site setup by Microsoft. But your customers could be behind cooperative firewalls that make this test unusable even when Internet
    access is available though other means (e.g. via a local proxy server). If you want to connect to your own web site, then you can skip that and just connect to your web site instead. Even if you were able to connect to Microsoft's web site there is no guarantee
    your web site would be accessible in the same network.
    Visual C++ MVP

  • Can somebody explain this store procedure

    Hi there
    can somebody explain me this Oracle store procedure, I am not able to figure it out anything from this SP :(
    CREATE OR REPLACE PROCEDURE MyDummySchema.MyDummyStoreProcedure
    (a_created_by_proc SomethingDummy.CREATED_BY_PROC%TYPE)
    as
    BEGIN
    /* Set up your global variables */
    XYZ_FORMAT.g_s_created_by_proc := a_created_by_proc;
    XYZ_FORMAT.g_d_current_time := sysdate;
    XYZ_GENERATEEODQUEUE.XYZ_GENERATEQUEUE;
    XYZ_PROCESSQUEUE.XYZ_PROCESSTRADES;
    XYZ_SYNC_SOMETHING(a_created_by_proc);
    END MyDummyStoreProcedure;

    Here
    XYZ_FORMAT, XYZ_GENERATEEODQUEUE, XYZ_PROCESSQUEUE
    are package names;
    XYZ_SYNC_SOMETHING is another PL/SQL procedure name; the procedure takes one parameter;
    XYZ_FORMAT.g_s_created_by_proc, XYZ_FORMAT.g_d_current_time are global variables defined in the package XYZ_FORMAT, in package definition part of it;
    XYZ_GENERATEEODQUEUE.XYZ_GENERATEQUEUE,
    XYZ_PROCESSQUEUE.XYZ_PROCESSTRADES are stored procedures w/o parameters definned in packages XYZ_GENERATEEODQUEUE and XYZ_PROCESSQUEUE respectively.
    But only the author [hopefully] knows what is the point of all this stuff :)

  • Could somebody explain to me how to become a beta tester?

    Could somebody explain to me how to become a beta tester?

    Signup as a $99/year developer, sign the non-disclosure aggrement, and Apple will make pre-release versions of iOS and Mac OS X software available to you.
    <https://developer.apple.com/>
    <https://developer.apple.com/membercenter/>

  • ESCAPE Option can somebody explain it ?

    ESCAPE Option can somebody explain it ?
    Thanks in anticipation
    SDG

    In first SELECT the underscore is intrepreted as any one single character. What if we wanted to search for an underscore specifically. The second example allows us to search specifically for underscore character with LIKE.
    SQL> select table_name from dba_tables where table_name like 'DBMS_%' ;
    TABLE_NAME
    DBMS_ALERT_INFO
    DBMS_LOCK_ALLOCATED
    DBMSALERTINFO
    3 rows selected.
    SQL> select table_name from dba_tables where table_name like 'DBMS\_%' ESCAPE '\' ;
    TABLE_NAME
    DBMS_ALERT_INFO
    DBMS_LOCK_ALLOCATED
    2 rows selected.
    SQL>Sorry Nicolas, your post was not visible at that time.
    Message was edited by:
    Kamal Kishore

  • I bought a bluetooth earpiece to be used with my ipad. But my ipad could not detect the earpiece. My friend's other tablet was able to detect my earpiece. Can somebody explain to me why my ipad could not detect my earpiece.

    I bought a bluetooth earpiece for my ipad but my ipad could not detect the earpiece. Can somebody explain why that is so? I used the piece on my friend's tablet and it could detect the earpiece meaning that it is working. Why my ipad could'n? I want to use it to listen to music or video. I could use the normal wire type earpiece but it is very cumbersome.

    I bought a bluetooth earpiece for my ipad but my ipad could not detect the earpiece. Can somebody explain why that is so? I used the piece on my friend's tablet and it could detect the earpiece meaning that it is working. Why my ipad could'n? I want to use it to listen to music or video. I could use the normal wire type earpiece but it is very cumbersome.

  • Method chaining and casting

    I was wondering if anyone knows whether it is possible to somehow apply method chaining on an object that requires a cast.
    For example:
    ArrayList ar = new ArrayList();
    ar.add(new Integer(3));
    int i = ar.get(0).intValue();The third line obviously produces a compile error to the effect that you can't call method intValue() on object Object.
    To get the int value from the ArrayList above I have to do the following:
    ArrayList ar = new ArrayList();
    ar.add(new Integer(3));
    Integer intObject = (Integer)ar.get(0);
    int i = intObject.intValue();Is it at all possible to get the int value somehow without explicitly creating an Integer object? Is there a possible way to combine method chaining and casting in this case?

    You may combine the two lines by casting at the same time:
    int i = ((Integer)ar.get(0)).intValue();
    Notice the additional brackets to help the compiler understand the precedence of your intentions. It makes no sense if the compile tries to call intValue THEN cast to Integer.
    When you call:
    Integer intObject = (Integer)ar.get(0);
    No Integer object is created, only a reference to the object is created. I'm not sure if an implicit reference is created in the previous example, but I see no substantial benefit using the first method. In fact I won't use it as its not very readable (to me).

  • Method Chaining

    Hi all,
    I have these method chaining:
    boolean b = Services.getInstance().getEntitleReferenceService().getUser(username) != null;
    As I understood, I have to follow the method chain from right to left, right?
    Services.getInstance()> returns an object of type: Services
    On the Services object, I call the method: getEntitleReferenceService()
    this method returns an object of type: EntitlementsReferenceService which is object of type interface: EntitlementsReferenceService
    The only class that implements that interface is: RemoteEntitleReferenceService.java
    In RemoteEntitleReferenceService.java, I have the method: getUser(String userID)
    The point is that the method: getUser() does NOT return boolean as expected!
    This is the method signature:
    public User getUser(final String userId){}
    I have this part of code in Intellij and it does not show an error as it usually does when these kind of error happens.
    Does anybody has any idea that where am I making a mistake? Any help is greatly appreciated.

    The point is that the method: getUser() does NOT return boolean as expected! Nobody expects it to. It'll return a reference, which will be evaluated against null, and the reult of that gets assigned to the boolean.

  • Method Chaining - Benefit?

    Hiii...
    I have read about Method Chaining like
    obj.method1().method2().method3();
    Its easy for development like you are concatinating 3 calls into 1, but I want to know whether its improving perfromance something or not?
    Thanks..

    endasil wrote:
    georgemc wrote:
    String url = new StringBuilder("file://")
    .append(baseUrl).append(File.separator)
    .append(resourceDir).append(File.separator)
    .append(resourceName)
    .append(extension).toString();Now you can just read down the "right-hand column" and see what the url string is composed of.Forgive my ignorance, but how is that example better than
    String url = "file://" +
    baseURL + File.separator +
    resourceDir + File.separator +
    resourceName +
    extension;I don't mean to attack an example whose purpose was something different (it correctly showed why chain methods), but I just thought I'd ask. It seems to me like using a StringBuilder really only has benefit if you're going to be building the string dynamically/not all in one statement. Otherwise just using String concatenation seems cleaner.:sigh: I'm not being side-tracked here. By your own admission, the example was to demonstrate method chaining.

  • Can somebody explain this strange method overloading behavior

    Please check the following code out......
    Snippet 1) compiles while Snippet 2) does not. Can someone explain. Thanks in advance for your help.
    Snippet 1)
    public class AQuestion
    public void method(Object o)
    System.out.println("Object Verion");
    public void method(String s)
    System.out.println("String Version");
    public static void main(String args[])
    AQuestion question = new AQuestion();
    question.method(null);
    // second version of this code.....
    Snippet 2)
    public class AQuestion
    public void method(StringBuffer sb)
    System.out.println("StringBuffer Verion");
    public void method(String s)
    System.out.println("String Version");
    public static void main(String args[])
    AQuestion question = new AQuestion();
    question.method(null);

    foo( SuperClass parm ) {}
    foo( SubClass parm ) {}
    Now somewhere in your code you do this:
    SuperClass myVar = new SubClass();
    foo( myVar );Which one do you want the JVM to call? Well, you want
    it to call the more specific one.
    So it calls foo( SubClass ). But if you sayNo, it doesnt. At compile time the compiler cannot know the complete type of myVar. It can only assure that myVar is of the type SuperClass. And it inserts no dynamic type-checking. And therefore it calls foo(SuperClass).
    It also does that if myVar is null (no dynamic type checking).
    SuperClass myVar = null;
    foo( myVar );
    foo(SuperClass) is called !!!
    foo(null);
    foo(SubClass) is called.
    SuperClass myVar = new SubClass();
    foo( myVar );
    SuperClass myVar = new SuperClass();
    foo( myVar );
    Can you cast myVar as an instance of SuperClass?
    yes.
    Can you cast myVar as an instance of SubClass?
    No.
    This is true of null; null can be cast as SuperClass
    or SubClass.
    No I dont think so. because null doesnt provide any method specified in SuperClass. Thus there can't be done a type cast. Null must be treated specially. It simply fits every class type at compile time.
    If the static (known at compile time) type of a parameter is known (not null) then the method with exactly the same parameter type is called or the one with the most specific parameter type in the line of inheritance of the given parameter - independent from the dynamic (known at runtime) type of the given parameter. If the parameter is null and if there is only one "line of inheritance" then null matches the most specific type by definition. If there are more "lines of inheritance" for the parameters then null would match each most specific type, and thus its not clear which method to use.
    I think this has nothin to do with type casts.

Maybe you are looking for

  • Display value in detail portion different than in table

    I'm saving a 1 character value in a table via a form. I'd like to display a longer description of that item in another item when the master item is selected and the execute_query commands runs for the detailed portion of the form. Is there anyway to

  • Help needed in connecting a Mac Mini to AT&T DSL

    Any suggestions on how to troubleshoot this problem will be appreciated. I'm helping a friend connect a Mac to the Internet using AT&T DSL. The computer is a Mac Mini, 1.42 GHz PPC G4, running OS X 10.5. It is connected by Ethernet to an AT&T DSL mod

  • Video problems.

    I'm a bit new to this, so I apologize in advance if these questions have already been addressed somewhere. If they have been then I couldn't seem to find them. Two problems with videos. Quicktime files that refuse to transfer to the iPod. They play f

  • Is there ARE-1 & ARE-3 functionality in 4.6c CIN version?

    I am working on the roll out of 4.6c.I am facing one problem in CIN. 1.   In SPRO ,"Settings under Export regulation" is missing. 2.   Excise transaction types (ETT) are not present in CIN: ARE1,ARE3 3.   J1IBN01- Creating Excise Bond. 4.   J1IA101-

  • How to restore photo file after empty trash

    photos file have been deleted and trash is empty.  please advise how to restore. many thx! cheers